Le chargement de tinymce et des webshims est maintenant fonctionnel, y compris avec turbolinks. Ajout d'un spinner pour indiquer le chargement

This commit is contained in:
echarp 2014-07-17 16:45:12 +02:00
parent 2b33c37c9b
commit 8532c88097
164 changed files with 126406 additions and 13 deletions

View File

@ -41,9 +41,6 @@ Puis lancez rails:
~ $ bundle exec rails s
}}}
En production, dans le répertoire source, vous devez aussi:
~ rake webshims:update_public
Vous pouvez finalement accéder à l'agenda dans un navigateur à l'URL suivante:
http://localhost:3000

View File

@ -14,7 +14,7 @@
#= require jquery_ujs
#= require jquery.turbolinks
#= require turbolinks
#= require tinymce
#= require tinymce-jquery
#= require modernizr
#= require webshims/polyfiller
#= require_tree .
@ -22,25 +22,37 @@
# Setup polyfills, so that older browsers can also take advanage of html5!
#$.webshims.setOptions('basePath', '/assets/webshims/shims/')
$.webshims.setOptions('basePath', '/webshims/shims/')
$.webshims.polyfill('es5 forms forms-ext mediaelement')
$.webshims.polyfill('forms forms-ext')
$(document).ready ->
$(document).on 'page:fetch submit', ->
$('em#loading').fadeIn('slow')
$(document).on 'page:receive', ->
$('em#loading').fadeOut('slow')
$(document).on 'page:load', ->
# Reload polyfill when turbolinks loads a new page
$(this).updatePolyfill()
tinyMCE.init {
$(document).on 'page:receive', ->
# Delete existing tinymce editors, very important in the turbolinks context!
tinymce.remove()
$(document).ready ->
tinyMCE.init
selector: 'textarea',
language: 'fr_FR',
menubar : false,
schema: 'html5',
add_unload_trigger: true,
browser_spellcheck: true,
toolbar: [
' bold italic strikethrough
| bullist numlist outdent indent
| alignleft aligncenter alignright alignjustify
| link media insertdatetime charmap table
| undo redo
| searchreplace spellchecker
| searchreplace
| code visualblocks preview fullscreen'
],
plugins: 'lists, advlist, autolink, link, charmap, paste, print, preview,
table, fullscreen, searchreplace, media, insertdatetime, visualblocks,
visualchars, wordcount, contextmenu, code, spellchecker'
}
visualchars, wordcount, contextmenu, code'

View File

@ -7,7 +7,6 @@
max-width: 100%
box-sizing: border-box
line-height: 1em
@include transition-duration(0.5s)
html
color: black
@ -23,6 +22,9 @@ body
text-align: center
border-bottom: 0px
background-color: white
header, main, footer
*
@include transition-duration(0.5s)
a:link, a:visited
color: #258
@ -177,3 +179,13 @@ footer.bottom nav
color: black
content: '- '
font-weight: normal
#loading
top: 45%
left: 45%
color: gray
display: none
position: fixed
font-size: 10vw
vertical-align: baseline
@include text-shadow(0 0 4px gray)

View File

@ -33,7 +33,7 @@
:markdown
#{t '.description_helper'}
= f.label :description
= f.text_area :description, required: true, rows: 29, cols: 80
= f.text_area :description, required: true, rows: 25, cols: 90
.field
= f.label :city

View File

@ -67,3 +67,5 @@
= link_to t('.stats'), stats_regions_url
= link_to t('.contact'), application_contact_url
= link_to t('.moderation'), moderations_url
%em#loading.fa.fa-spin.fa-circle-o-notch

View File

@ -0,0 +1,511 @@
/* Modernizr 2.7.1 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-canvas-audio-video-input-inputtypes-geolocation-shiv-addtest-prefixed-testprop-testallprops-prefixes-domprefixes
*/
;
window.Modernizr = (function( window, document, undefined ) {
var version = '2.7.1',
Modernizr = {},
docElement = document.documentElement,
mod = 'modernizr',
modElem = document.createElement(mod),
mStyle = modElem.style,
inputElem = document.createElement('input') ,
smile = ':)',
toString = {}.toString,
prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
omPrefixes = 'Webkit Moz O ms',
cssomPrefixes = omPrefixes.split(' '),
domPrefixes = omPrefixes.toLowerCase().split(' '),
tests = {},
inputs = {},
attrs = {},
classes = [],
slice = classes.slice,
featureName,
_hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
hasOwnProp = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProp = function (object, property) {
return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
};
}
if (!Function.prototype.bind) {
Function.prototype.bind = function bind(that) {
var target = this;
if (typeof target != "function") {
throw new TypeError();
}
var args = slice.call(arguments, 1),
bound = function () {
if (this instanceof bound) {
var F = function(){};
F.prototype = target.prototype;
var self = new F();
var result = target.apply(
self,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return self;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
return bound;
};
}
function setCss( str ) {
mStyle.cssText = str;
}
function setCssAll( str1, str2 ) {
return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
}
function is( obj, type ) {
return typeof obj === type;
}
function contains( str, substr ) {
return !!~('' + str).indexOf(substr);
}
function testProps( props, prefixed ) {
for ( var i in props ) {
var prop = props[i];
if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {
return prefixed == 'pfx' ? prop : true;
}
}
return false;
}
function testDOMProps( props, obj, elem ) {
for ( var i in props ) {
var item = obj[props[i]];
if ( item !== undefined) {
if (elem === false) return props[i];
if (is(item, 'function')){
return item.bind(elem || obj);
}
return item;
}
}
return false;
}
function testPropsAll( prop, prefixed, elem ) {
var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
if(is(prefixed, "string") || is(prefixed, "undefined")) {
return testProps(props, prefixed);
} else {
props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
return testDOMProps(props, prefixed, elem);
}
}
tests['canvas'] = function() {
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}; tests['geolocation'] = function() {
return 'geolocation' in navigator;
};
tests['video'] = function() {
var elem = document.createElement('video'),
bool = false;
try {
if ( bool = !!elem.canPlayType ) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('video/ogg; codecs="theora"') .replace(/^no$/,'');
bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
}
} catch(e) { }
return bool;
};
tests['audio'] = function() {
var elem = document.createElement('audio'),
bool = false;
try {
if ( bool = !!elem.canPlayType ) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');
bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,'');
bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,'');
bool.m4a = ( elem.canPlayType('audio/x-m4a;') ||
elem.canPlayType('audio/aac;')) .replace(/^no$/,'');
}
} catch(e) { }
return bool;
}; function webforms() {
Modernizr['input'] = (function( props ) {
for ( var i = 0, len = props.length; i < len; i++ ) {
attrs[ props[i] ] = !!(props[i] in inputElem);
}
if (attrs.list){
attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
}
return attrs;
})('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
Modernizr['inputtypes'] = (function(props) {
for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
inputElem.setAttribute('type', inputElemType = props[i]);
bool = inputElem.type !== 'text';
if ( bool ) {
inputElem.value = smile;
inputElem.style.cssText = 'position:absolute;visibility:hidden;';
if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
docElement.appendChild(inputElem);
defaultView = document.defaultView;
bool = defaultView.getComputedStyle &&
defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
(inputElem.offsetHeight !== 0);
docElement.removeChild(inputElem);
} else if ( /^(search|tel)$/.test(inputElemType) ){
} else if ( /^(url|email)$/.test(inputElemType) ) {
bool = inputElem.checkValidity && inputElem.checkValidity() === false;
} else {
bool = inputElem.value != smile;
}
}
inputs[ props[i] ] = !!bool;
}
return inputs;
})('search tel url email datetime date month week time datetime-local number range color'.split(' '));
}
for ( var feature in tests ) {
if ( hasOwnProp(tests, feature) ) {
featureName = feature.toLowerCase();
Modernizr[featureName] = tests[feature]();
classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
}
}
Modernizr.input || webforms();
Modernizr.addTest = function ( feature, test ) {
if ( typeof feature == 'object' ) {
for ( var key in feature ) {
if ( hasOwnProp( feature, key ) ) {
Modernizr.addTest( key, feature[ key ] );
}
}
} else {
feature = feature.toLowerCase();
if ( Modernizr[feature] !== undefined ) {
return Modernizr;
}
test = typeof test == 'function' ? test() : test;
if (typeof enableClasses !== "undefined" && enableClasses) {
docElement.className += ' ' + (test ? '' : 'no-') + feature;
}
Modernizr[feature] = test;
}
return Modernizr;
};
setCss('');
modElem = inputElem = null;
;(function(window, document) {
var version = '3.7.0';
var options = window.html5 || {};
var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
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;
var supportsHtml5Styles;
var expando = '_html5shiv';
var expanID = 0;
var expandoData = {};
var supportsUnknownElements;
(function() {
try {
var a = document.createElement('a');
a.innerHTML = '<xyz></xyz>';
supportsHtml5Styles = ('hidden' in a);
supportsUnknownElements = a.childNodes.length == 1 || (function() {
(document.createElement)('a');
var frag = document.createDocumentFragment();
return (
typeof frag.cloneNode == 'undefined' ||
typeof frag.createDocumentFragment == 'undefined' ||
typeof frag.createElement == 'undefined'
);
}());
} catch(e) {
supportsHtml5Styles = true;
supportsUnknownElements = true;
}
}());
function addStyleSheet(ownerDocument, cssText) {
var p = ownerDocument.createElement('p'),
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
p.innerHTML = 'x<style>' + cssText + '</style>';
return parent.insertBefore(p.lastChild, parent.firstChild);
}
function getElements() {
var elements = html5.elements;
return typeof elements == 'string' ? elements.split(' ') : elements;
}
function getExpandoData(ownerDocument) {
var data = expandoData[ownerDocument[expando]];
if (!data) {
data = {};
expanID++;
ownerDocument[expando] = expanID;
expandoData[expanID] = data;
}
return data;
}
function createElement(nodeName, ownerDocument, data){
if (!ownerDocument) {
ownerDocument = document;
}
if(supportsUnknownElements){
return ownerDocument.createElement(nodeName);
}
if (!data) {
data = getExpandoData(ownerDocument);
}
var node;
if (data.cache[nodeName]) {
node = data.cache[nodeName].cloneNode();
} else if (saveClones.test(nodeName)) {
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
} else {
node = data.createElem(nodeName);
}
return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
}
function createDocumentFragment(ownerDocument, data){
if (!ownerDocument) {
ownerDocument = document;
}
if(supportsUnknownElements){
return ownerDocument.createDocumentFragment();
}
data = data || getExpandoData(ownerDocument);
var clone = data.frag.cloneNode(),
i = 0,
elems = getElements(),
l = elems.length;
for(;i<l;i++){
clone.createElement(elems[i]);
}
return clone;
}
function shivMethods(ownerDocument, data) {
if (!data.cache) {
data.cache = {};
data.createElem = ownerDocument.createElement;
data.createFrag = ownerDocument.createDocumentFragment;
data.frag = data.createFrag();
}
ownerDocument.createElement = function(nodeName) {
if (!html5.shivMethods) {
return data.createElem(nodeName);
}
return createElement(nodeName, ownerDocument, data);
};
ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
'var n=f.cloneNode(),c=n.createElement;' +
'h.shivMethods&&(' +
getElements().join().replace(/[\w\-]+/g, function(nodeName) {
data.createElem(nodeName);
data.frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
');return n}'
)(html5, data.frag);
}
function shivDocument(ownerDocument) {
if (!ownerDocument) {
ownerDocument = document;
}
var data = getExpandoData(ownerDocument);
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
data.hasCSS = !!addStyleSheet(ownerDocument,
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
'mark{background:#FF0;color:#000}' +
'template{display:none}'
);
}
if (!supportsUnknownElements) {
shivMethods(ownerDocument, data);
}
return ownerDocument;
}
var html5 = {
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video',
'version': version,
'shivCSS': (options.shivCSS !== false),
'supportsUnknownElements': supportsUnknownElements,
'shivMethods': (options.shivMethods !== false),
'type': 'default',
'shivDocument': shivDocument,
createElement: createElement,
createDocumentFragment: createDocumentFragment
};
window.html5 = html5;
shivDocument(document);
}(this, document));
Modernizr._version = version;
Modernizr._prefixes = prefixes;
Modernizr._domPrefixes = domPrefixes;
Modernizr._cssomPrefixes = cssomPrefixes;
Modernizr.testProp = function(prop){
return testProps([prop]);
};
Modernizr.testAllProps = testPropsAll;
Modernizr.prefixed = function(prop, obj, elem){
if(!obj) {
return testPropsAll(prop, 'pfx');
} else {
return testPropsAll(prop, obj, elem);
}
};
return Modernizr;
})(this, this.document);
;
if(window.console){
console.log('webshim no longer depends on Modernizr. You can still use for feature detection of course.');
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
/*
* canvas2png.js
*
* Copyright (c) 2010-2013 Shinya Muramatsu
* Released under the MIT License
* http://flashcanvas.net/
*/
(function(doc) {
var scripts = doc.getElementsByTagName("script");
var script = scripts[scripts.length - 1];
var url = script.getAttribute("src").replace(/[^\/]+$/, "save.php");
window.canvas2png = function(canvas, filename) {
var tagName = canvas.tagName.toLowerCase();
if (tagName !== "canvas") {
return;
}
if (typeof FlashCanvas !== "undefined") {
FlashCanvas.saveImage(canvas, filename);
} else {
var action = url;
if (filename) {
action += "?filename=" + filename;
}
var form = doc.createElement("form");
var input = doc.createElement("input");
form.setAttribute("action", action);
form.setAttribute("method", "post");
input.setAttribute("type", "hidden");
input.setAttribute("name", "dataurl");
input.setAttribute("value", canvas.toDataURL());
doc.body.appendChild(form);
form.appendChild(input);
form.submit();
form.removeChild(input);
doc.body.removeChild(form);
}
}
})(document);

View File

@ -0,0 +1,54 @@
window.FlashCanvasOptions = window.FlashCanvasOptions || {};
webshims.$.extend(FlashCanvasOptions, {
swfPath: webshims.cfg.basePath + 'FlashCanvas/'
});
/*
* FlashCanvas
*
* Copyright (c) 2009 Tim Cameron Ryan
* Copyright (c) 2009-2013 FlashCanvas Project
* Released under the MIT/X License
*/
window.ActiveXObject&&!window.CanvasRenderingContext2D&&function(i,j,z){function D(a){this.code=a;this.message=R[a]}function S(a){this.width=a}function v(a){this.id=a.C++}function k(a){this.G=a;this.id=a.C++}function m(a,b){this.canvas=a;this.B=b;this.d=b.id.slice(8);this.D();this.C=0;this.f=this.u="";var c=this;setInterval(function(){o[c.d]===0&&c.e()},30)}function A(){if(j.readyState==="complete"){j.detachEvent(E,A);for(var a=j.getElementsByTagName(r),b=0,c=a.length;b<c;++b)B.initElement(a[b])}}
function F(){var a=event.srcElement,b=a.parentNode;a.blur();b.focus()}function G(){var a=event.propertyName;if(a==="width"||a==="height"){var b=event.srcElement,c=b[a],d=parseInt(c,10);if(isNaN(d)||d<0)d=a==="width"?300:150;c===d?(b.style[a]=d+"px",b.getContext("2d").I(b.width,b.height)):b[a]=d}}function H(){i.detachEvent(I,H);for(var a in s){var b=s[a],c=b.firstChild,d;for(d in c)typeof c[d]==="function"&&(c[d]=l);for(d in b)typeof b[d]==="function"&&(b[d]=l);c.detachEvent(J,F);b.detachEvent(K,G)}i[L]=
l;i[M]=l;i[N]=l;i[C]=l;i[O]=l}function T(){var a=j.getElementsByTagName("script"),a=a[a.length-1];return j.documentMode>=8?a.src:a.getAttribute("src",4)}function t(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;")}function U(a){return a.toLowerCase()}function h(a){throw new D(a);}function P(a){var b=parseInt(a.width,10),c=parseInt(a.height,10);if(isNaN(b)||b<0)b=300;if(isNaN(c)||c<0)c=150;a.width=b;a.height=c}var l=null,r="canvas",L="CanvasRenderingContext2D",M="CanvasGradient",N="CanvasPattern",
C="FlashCanvas",O="G_vmlCanvasManager",J="onfocus",K="onpropertychange",E="onreadystatechange",I="onunload",w=((i[C+"Options"]||{}).swfPath||T().replace(/[^\/]+$/,""))+"flashcanvas.swf",e=new function(a){for(var b=0,c=a.length;b<c;b++)this[a[b]]=b}("toDataURL,save,restore,scale,rotate,translate,transform,setTransform,globalAlpha,globalCompositeOperation,strokeStyle,fillStyle,createLinearGradient,createRadialGradient,createPattern,lineWidth,lineCap,lineJoin,miterLimit,shadowOffsetX,shadowOffsetY,shadowBlur,shadowColor,clearRect,fillRect,strokeRect,beginPath,closePath,moveTo,lineTo,quadraticCurveTo,bezierCurveTo,arcTo,rect,arc,fill,stroke,clip,isPointInPath,font,textAlign,textBaseline,fillText,strokeText,measureText,drawImage,createImageData,getImageData,putImageData,addColorStop,direction,resize".split(",")),
u={},p={},o={},x={},s={},y={};m.prototype={save:function(){this.b();this.c();this.n();this.m();this.z();this.w();this.F.push([this.g,this.h,this.A,this.v,this.k,this.i,this.j,this.l,this.q,this.r,this.o,this.p,this.f,this.s,this.t]);this.a.push(e.save)},restore:function(){var a=this.F;if(a.length)a=a.pop(),this.globalAlpha=a[0],this.globalCompositeOperation=a[1],this.strokeStyle=a[2],this.fillStyle=a[3],this.lineWidth=a[4],this.lineCap=a[5],this.lineJoin=a[6],this.miterLimit=a[7],this.shadowOffsetX=
a[8],this.shadowOffsetY=a[9],this.shadowBlur=a[10],this.shadowColor=a[11],this.font=a[12],this.textAlign=a[13],this.textBaseline=a[14];this.a.push(e.restore)},scale:function(a,b){this.a.push(e.scale,a,b)},rotate:function(a){this.a.push(e.rotate,a)},translate:function(a,b){this.a.push(e.translate,a,b)},transform:function(a,b,c,d,f,g){this.a.push(e.transform,a,b,c,d,f,g)},setTransform:function(a,b,c,d,f,g){this.a.push(e.setTransform,a,b,c,d,f,g)},b:function(){var a=this.a;if(this.g!==this.globalAlpha)this.g=
this.globalAlpha,a.push(e.globalAlpha,this.g);if(this.h!==this.globalCompositeOperation)this.h=this.globalCompositeOperation,a.push(e.globalCompositeOperation,this.h)},n:function(){if(this.A!==this.strokeStyle){var a=this.A=this.strokeStyle;if(typeof a!=="string")if(a instanceof k||a instanceof v)a=a.id;else return;this.a.push(e.strokeStyle,a)}},m:function(){if(this.v!==this.fillStyle){var a=this.v=this.fillStyle;if(typeof a!=="string")if(a instanceof k||a instanceof v)a=a.id;else return;this.a.push(e.fillStyle,
a)}},createLinearGradient:function(a,b,c,d){(!isFinite(a)||!isFinite(b)||!isFinite(c)||!isFinite(d))&&h(9);this.a.push(e.createLinearGradient,a,b,c,d);return new k(this)},createRadialGradient:function(a,b,c,d,f,g){(!isFinite(a)||!isFinite(b)||!isFinite(c)||!isFinite(d)||!isFinite(f)||!isFinite(g))&&h(9);(c<0||g<0)&&h(1);this.a.push(e.createRadialGradient,a,b,c,d,f,g);return new k(this)},createPattern:function(a,b){a||h(17);var c=a.tagName,d,f=this.d;if(c)if(c=c.toLowerCase(),c==="img")d=a.getAttribute("src",
2);else if(c===r||c==="video")return;else h(17);else a.src?d=a.src:h(17);b==="repeat"||b==="no-repeat"||b==="repeat-x"||b==="repeat-y"||b===""||b===l||h(12);this.a.push(e.createPattern,t(d),b);!p[f][d]&&u[f]&&(this.e(),++o[f],p[f][d]=!0);return new v(this)},z:function(){var a=this.a;if(this.k!==this.lineWidth)this.k=this.lineWidth,a.push(e.lineWidth,this.k);if(this.i!==this.lineCap)this.i=this.lineCap,a.push(e.lineCap,this.i);if(this.j!==this.lineJoin)this.j=this.lineJoin,a.push(e.lineJoin,this.j);
if(this.l!==this.miterLimit)this.l=this.miterLimit,a.push(e.miterLimit,this.l)},c:function(){var a=this.a;if(this.q!==this.shadowOffsetX)this.q=this.shadowOffsetX,a.push(e.shadowOffsetX,this.q);if(this.r!==this.shadowOffsetY)this.r=this.shadowOffsetY,a.push(e.shadowOffsetY,this.r);if(this.o!==this.shadowBlur)this.o=this.shadowBlur,a.push(e.shadowBlur,this.o);if(this.p!==this.shadowColor)this.p=this.shadowColor,a.push(e.shadowColor,this.p)},clearRect:function(a,b,c,d){this.a.push(e.clearRect,a,b,c,
d)},fillRect:function(a,b,c,d){this.b();this.c();this.m();this.a.push(e.fillRect,a,b,c,d)},strokeRect:function(a,b,c,d){this.b();this.c();this.n();this.z();this.a.push(e.strokeRect,a,b,c,d)},beginPath:function(){this.a.push(e.beginPath)},closePath:function(){this.a.push(e.closePath)},moveTo:function(a,b){this.a.push(e.moveTo,a,b)},lineTo:function(a,b){this.a.push(e.lineTo,a,b)},quadraticCurveTo:function(a,b,c,d){this.a.push(e.quadraticCurveTo,a,b,c,d)},bezierCurveTo:function(a,b,c,d,f,g){this.a.push(e.bezierCurveTo,
a,b,c,d,f,g)},arcTo:function(a,b,c,d,f){f<0&&isFinite(f)&&h(1);this.a.push(e.arcTo,a,b,c,d,f)},rect:function(a,b,c,d){this.a.push(e.rect,a,b,c,d)},arc:function(a,b,c,d,f,g){c<0&&isFinite(c)&&h(1);this.a.push(e.arc,a,b,c,d,f,g?1:0)},fill:function(){this.b();this.c();this.m();this.a.push(e.fill)},stroke:function(){this.b();this.c();this.n();this.z();this.a.push(e.stroke)},clip:function(){this.a.push(e.clip)},w:function(){var a=this.a;if(this.f!==this.font)try{var b=y[this.d];b.style.font=this.f=this.font;
var c=b.currentStyle;a.push(e.font,[c.fontStyle,c.fontWeight,b.offsetHeight,c.fontFamily].join(" "))}catch(d){}if(this.s!==this.textAlign)this.s=this.textAlign,a.push(e.textAlign,this.s);if(this.t!==this.textBaseline)this.t=this.textBaseline,a.push(e.textBaseline,this.t);if(this.u!==this.canvas.currentStyle.direction)this.u=this.canvas.currentStyle.direction,a.push(e.direction,this.u)},fillText:function(a,b,c,d){this.b();this.m();this.c();this.w();this.a.push(e.fillText,t(a),b,c,d===z?Infinity:d)},
strokeText:function(a,b,c,d){this.b();this.n();this.c();this.w();this.a.push(e.strokeText,t(a),b,c,d===z?Infinity:d)},measureText:function(a){var b=y[this.d];try{b.style.font=this.font}catch(c){}b.innerText=(""+a).replace(/[ \n\f\r]/g,"\t");return new S(b.offsetWidth)},drawImage:function(a,b,c,d,f,g,i,j,l){a||h(17);var k=a.tagName,n,q=arguments.length,m=this.d;if(k)if(k=k.toLowerCase(),k==="img")n=a.getAttribute("src",2);else if(k===r||k==="video")return;else h(17);else a.src?n=a.src:h(17);this.b();
this.c();n=t(n);if(q===3)this.a.push(e.drawImage,q,n,b,c);else if(q===5)this.a.push(e.drawImage,q,n,b,c,d,f);else if(q===9)(d===0||f===0)&&h(1),this.a.push(e.drawImage,q,n,b,c,d,f,g,i,j,l);else return;!p[m][n]&&u[m]&&(this.e(),++o[m],p[m][n]=!0)},loadImage:function(a,b,c){var d=a.tagName,f,g=this.d;if(d)d.toLowerCase()==="img"&&(f=a.getAttribute("src",2));else if(a.src)f=a.src;if(f&&!p[g][f]){if(b||c)x[g][f]=[a,b,c];this.a.push(e.drawImage,1,t(f));u[g]&&(this.e(),++o[g],p[g][f]=!0)}},D:function(){this.globalAlpha=
this.g=1;this.globalCompositeOperation=this.h="source-over";this.fillStyle=this.v=this.strokeStyle=this.A="#000000";this.lineWidth=this.k=1;this.lineCap=this.i="butt";this.lineJoin=this.j="miter";this.miterLimit=this.l=10;this.shadowBlur=this.o=this.shadowOffsetY=this.r=this.shadowOffsetX=this.q=0;this.shadowColor=this.p="rgba(0, 0, 0, 0.0)";this.font=this.f="10px sans-serif";this.textAlign=this.s="start";this.textBaseline=this.t="alphabetic";this.a=[];this.F=[]},H:function(){var a=this.a;this.a=
[];return a},e:function(){var a=this.H();if(a.length>0)return eval(this.B.CallFunction('<invoke name="executeCommand" returntype="javascript"><arguments><string>'+a.join("&#0;")+"</string></arguments></invoke>"))},I:function(a,b){this.e();this.D();if(a>0)this.B.width=a;if(b>0)this.B.height=b;this.a.push(e.resize,a,b)}};k.prototype={addColorStop:function(a,b){(isNaN(a)||a<0||a>1)&&h(1);this.G.a.push(e.addColorStop,this.id,a,b)}};D.prototype=Error();var R={1:"INDEX_SIZE_ERR",9:"NOT_SUPPORTED_ERR",11:"INVALID_STATE_ERR",
12:"SYNTAX_ERR",17:"TYPE_MISMATCH_ERR",18:"SECURITY_ERR"},B={initElement:function(a){if(a.getContext)return a;var b=Math.random().toString(36).slice(2)||"0",c="external"+b;u[b]=!1;p[b]={};o[b]=1;x[b]={};P(a);a.innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="'+c+'"><param name="allowScriptAccess" value="always"><param name="flashvars" value="id='+
c+'"><param name="wmode" value="transparent"></object><span style="margin:0;padding:0;border:0;display:inline-block;position:static;height:1em;overflow:visible;white-space:nowrap"></span>';s[b]=a;var d=a.firstChild;y[b]=a.lastChild;var f=j.body.contains;if(f(a))d.movie=w;else var g=setInterval(function(){if(f(a))clearInterval(g),d.movie=w},0);if(j.compatMode==="BackCompat"||!i.XMLHttpRequest)y[b].style.overflow="hidden";var h=new m(a,d);a.getContext=function(a){return a==="2d"?h:l};a.toDataURL=function(a,
b){(""+a).replace(/[A-Z]+/g,U)==="image/jpeg"?h.a.push(e.toDataURL,a,typeof b==="number"?b:""):h.a.push(e.toDataURL,a);return h.e()};d.attachEvent(J,F);return a},saveImage:function(a,b){a.firstChild.saveImage(b)},setOptions:function(){},trigger:function(a,b){s[a].fireEvent("on"+b)},unlock:function(a,b,c){var d,e,g;o[a]&&--o[a];if(b===z){d=s[a];b=d.firstChild;P(d);e=d.width;c=d.height;d.style.width=e+"px";d.style.height=c+"px";if(e>0)b.width=e;if(c>0)b.height=c;b.resize(e,c);d.attachEvent(K,G);u[a]=
!0;typeof d.onload==="function"&&setTimeout(function(){d.onload()},0)}else if(g=x[a][b])e=g[0],c=g[1+c],delete x[a][b],typeof c==="function"&&c.call(e)}};j.createElement(r);j.createStyleSheet().cssText=r+"{display:inline-block;overflow:hidden;width:300px;height:150px}";j.readyState==="complete"?A():j.attachEvent(E,A);i.attachEvent(I,H);if(w.indexOf(location.protocol+"//"+location.host+"/")===0){var Q=new ActiveXObject("Microsoft.XMLHTTP");Q.open("GET",w,!1);Q.send(l)}i[L]=m;i[M]=k;i[N]=v;i[C]=B;i[O]=
{init:function(){},init_:function(){},initElement:B.initElement};keep=[m.measureText,m.loadImage]}(window,document);
(function(document){
webshims.addReady(function(context, elem){
if(context == document){
if(window.G_vmlCanvasManager && G_vmlCanvasManager.init_ ){
G_vmlCanvasManager.init_(document);
}
}
webshims.$('canvas', context).add(elem.filter('canvas')).each(function(){
var hasContext = this.getContext;
if(!hasContext && window.G_vmlCanvasManager){
G_vmlCanvasManager.initElement(this);
}
});
});
webshims.isReady('canvas', true);
})(document);

Binary file not shown.

View File

@ -0,0 +1,94 @@
<?php
/**
* Proxy script to load a file from other domain
*
* PHP versions 4 and 5
*
* Copyright (c) 2010-2013 Shinya Muramatsu
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Shinya Muramatsu <revulon@gmail.com>
* @copyright 2010-2013 Shinya Muramatsu
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @link http://flashcanvas.net/
* @link http://code.google.com/p/flashcanvas/
*/
function getHostName() {
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
return $_SERVER['HTTP_X_FORWARDED_HOST'];
} else if (isset($_SERVER['HTTP_HOST'])) {
return $_SERVER['HTTP_HOST'];
} else {
return $_SERVER['SERVER_NAME'];
}
}
// Whether we check referrer or not
define('CHECK_REFERRER', true);
// If necessary, specify the host where the SWF file is located
define('SWF_HOST_NAME', '');
// Check that the request comes from the same host
if (CHECK_REFERRER) {
if (empty($_SERVER['HTTP_REFERER'])) {
exit;
}
if (SWF_HOST_NAME) {
$host = SWF_HOST_NAME;
} else {
$host = getHostName();
}
$pattern = '#^https?://' . str_replace('.', '\.', $host) . '(:\d*)?/#';
if (!preg_match($pattern, $_SERVER['HTTP_REFERER'])) {
exit;
}
}
// Check that the request has a valid URL parameter
if (empty($_GET['url'])) {
exit;
}
if (!preg_match('#^https?://#', $_GET['url'])) {
exit;
}
// Percent-encode special characters in the URL
$search = array( '%', '#', ' ');
$replace = array('%25', '%23', '%20');
$url = str_replace($search, $replace, $_GET['url']);
// Disable compression
header('Content-Encoding: none');
// Load and output the file
if (extension_loaded('curl')) {
// Use cURL extension
$ch = curl_init($url);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_exec($ch);
curl_close($ch);
} else {
// Use the http:// wrapper
readfile($url);
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Save the input as a PNG file
*
* PHP versions 4 and 5
*
* Copyright (c) 2010-2013 Shinya Muramatsu
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Shinya Muramatsu <revulon@gmail.com>
* @copyright 2010-2013 Shinya Muramatsu
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @link http://flashcanvas.net/
* @link http://code.google.com/p/flashcanvas/
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_GET['filename'])) {
$filename = $_GET['filename'];
} else {
$filename = 'canvas.png';
}
// Force download
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
if (isset($_POST['dataurl'])) {
// Decode the base64-encoded data
$data = $_POST['dataurl'];
$data = substr($data, strpos($data, ',') + 1);
echo base64_decode($data);
} else {
// Output the raw data
readfile('php://input');
}
}

View File

@ -0,0 +1,47 @@
/*
* canvas2png.js
*
* Copyright (c) 2010-2013 Shinya Muramatsu
* Released under the MIT License
* http://flashcanvas.net/
*/
(function(doc) {
var scripts = doc.getElementsByTagName("script");
var script = scripts[scripts.length - 1];
var url = script.getAttribute("src").replace(/[^\/]+$/, "save.php");
window.canvas2png = function(canvas, filename) {
var tagName = canvas.tagName.toLowerCase();
if (tagName !== "canvas") {
return;
}
if (typeof FlashCanvas !== "undefined") {
FlashCanvas.saveImage(canvas, filename);
} else {
var action = url;
if (filename) {
action += "?filename=" + filename;
}
var form = doc.createElement("form");
var input = doc.createElement("input");
form.setAttribute("action", action);
form.setAttribute("method", "post");
input.setAttribute("type", "hidden");
input.setAttribute("name", "dataurl");
input.setAttribute("value", canvas.toDataURL());
doc.body.appendChild(form);
form.appendChild(input);
form.submit();
form.removeChild(input);
doc.body.removeChild(form);
}
}
})(document);

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,57 @@
window.FlashCanvasOptions = window.FlashCanvasOptions || {};
webshims.$.extend(FlashCanvasOptions, {
swfPath: webshims.cfg.basePath + 'FlashCanvasPro/'
});
/*
* FlashCanvas Pro
*
* Copyright (c) 2009 Tim Cameron Ryan
* Copyright (c) 2009-2013 Shinya Muramatsu
*/
window.ActiveXObject&&!window.CanvasRenderingContext2D&&function(l,k,q){function O(a){this.code=a;this.message=ga[a]}function w(a,b,c){if(!c)for(var c=[],d=0,e=a*b*4;d<e;++d)c[d]=0;this.width=a;this.height=b;this.data=c}function ha(a){this.width=a}function x(a){this.id=a.F++}function o(a){this.J=a;this.id=a.F++}function A(a,b){this.canvas=a;this.z=b;this.e=b.id.slice(8);this.G();this.F=0;this.j=this.D="";this.d=0}function B(){if(k.readyState==="complete"){k.detachEvent(P,B);for(var a=k.getElementsByTagName(r),
b=0,c=a.length;b<c;++b)C.initElement(a[b])}}function Q(){var a=event.srcElement,b=a.parentNode;a.blur();b.focus()}function D(){event.button&2&&event.srcElement.parentNode.setCapture()}function E(){event.button&2&&event.srcElement.parentNode.releaseCapture()}function R(){var a=event.propertyName;if(a==="width"||a==="height"){var b=event.srcElement,c=b[a],d=parseInt(c,10);if(isNaN(d)||d<0)d=a==="width"?300:150;c===d?(b.style[a]=d+"px",b.getContext("2d").K(b.width,b.height)):b[a]=d}}function S(){l.detachEvent(T,
S);for(var a in m){var b=m[a],c=b.firstChild,d;for(d in c)typeof c[d]==="function"&&(c[d]=g);for(d in b)typeof b[d]==="function"&&(b[d]=g);c.detachEvent(U,Q);c.detachEvent(F,D);b.detachEvent(G,E);b.detachEvent(V,R)}l[W]=g;l[X]=g;l[Y]=g;l[H]=g;l[Z]=g}function ia(a){return a.toLowerCase()}function i(a){throw new O(a);}function $(a){var b=parseInt(a.width,10),c=parseInt(a.height,10);if(isNaN(b)||b<0)b=300;if(isNaN(c)||c<0)c=150;a.width=b;a.height=c}function I(a,b){for(var c in m){var d=m[c].getContext("2d");
d.g.push(d.a.length+2);d.a.push(y,a,b)}}var g=null,r="canvas",W="CanvasRenderingContext2D",X="CanvasGradient",Y="CanvasPattern",H="FlashCanvas",Z="G_vmlCanvasManager",U="onfocus",F="onmousedown",G="onmouseup",V="onpropertychange",P="onreadystatechange",T="onunload",n;try{n=(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version").match(/[\d,]+/)[0].replace(/,/g,".")}catch(ka){n=0}var j=l[H+"Options"]||{},J=function(){var a=k.getElementsByTagName("script"),a=a[a.length-1];return k.documentMode>=
8?a.src:a.getAttribute("src",4)}().replace(/[^\/]+$/,""),t=j.swfPath||J;t+=parseInt(n)>9?"flash10canvas.swf":"flash9canvas.swf";var y="4",s={},u={},aa={},K={},p={},ba={},v={},m={},z={},J="autoinit"in j?j.autoinit:1,L="turbo"in j?j.turbo:1,M=j.delay||0,ca=j.disableContextMenu||0,da=j.imageCacheSize||100,N=j.usePolicyFile||0,ea=j.proxy||"proxy.php",fa=j.save||"save.php";n==="10.1.53.64"&&(L=0,M=30);A.prototype={save:function(){this.h(15);this.I.push([this.m,this.n,this.w,this.l,this.q,this.o,this.p,
this.r,this.u,this.v,this.s,this.t,this.j,this.A,this.B]);this.a.push("B")},restore:function(){var a=this.I;if(a.length)a=a.pop(),this.globalAlpha=a[0],this.globalCompositeOperation=a[1],this.strokeStyle=a[2],this.fillStyle=a[3],this.lineWidth=a[4],this.lineCap=a[5],this.lineJoin=a[6],this.miterLimit=a[7],this.shadowOffsetX=a[8],this.shadowOffsetY=a[9],this.shadowBlur=a[10],this.shadowColor=a[11],this.font=a[12],this.textAlign=a[13],this.textBaseline=a[14];this.a.push("C")},scale:function(a,b){this.a.push("D",
a,b)},rotate:function(a){this.a.push("E",a)},translate:function(a,b){this.a.push("F",a,b)},transform:function(a,b,c,d,e,f){this.a.push("G",a,b,c,d,e,f)},setTransform:function(a,b,c,d,e,f){this.a.push("H",a,b,c,d,e,f)},createLinearGradient:function(a,b,c,d){(!isFinite(a)||!isFinite(b)||!isFinite(c)||!isFinite(d))&&i(9);this.a.push("M",a,b,c,d);return new o(this)},createRadialGradient:function(a,b,c,d,e,f){(!isFinite(a)||!isFinite(b)||!isFinite(c)||!isFinite(d)||!isFinite(e)||!isFinite(f))&&i(9);(c<
0||f<0)&&i(1);this.a.push("N",a,b,c,d,e,f);return new o(this)},createPattern:function(a,b){a||i(17);var c=a.tagName,d,e,f,h=this.e;if(c)if(c=c.toLowerCase(),c==="img")d=a.getAttribute("src",2);else if(c===r)e=this.C(a),f=a!==this.canvas;else if(c==="video")return;else i(17);else a.src?d=a.src:i(17);b==="repeat"||b==="no-repeat"||b==="repeat-x"||b==="repeat-y"||b===""||b===g||i(12);e||(e=u[h][d],(f=e===q)&&(e=this.k(d)));this.a.push("O",e,b);f&&s[h]&&(this.f(),++p[h]);return new x(this)},clearRect:function(a,
b,c,d){this.a.push("X",a,b,c,d);this.b||this.c();this.d=0},fillRect:function(a,b,c,d){this.h(1);this.a.push("Y",a,b,c,d);this.b||this.c();this.d=0},strokeRect:function(a,b,c,d){this.h(6);this.a.push("Z",a,b,c,d);this.b||this.c();this.d=0},beginPath:function(){this.a.push("a")},closePath:function(){this.a.push("b")},moveTo:function(a,b){this.a.push("c",a,b)},lineTo:function(a,b){this.a.push("d",a,b)},quadraticCurveTo:function(a,b,c,d){this.a.push("e",a,b,c,d)},bezierCurveTo:function(a,b,c,d,e,f){this.a.push("f",
a,b,c,d,e,f)},arcTo:function(a,b,c,d,e){e<0&&isFinite(e)&&i(1);this.a.push("g",a,b,c,d,e)},rect:function(a,b,c,d){this.a.push("h",a,b,c,d)},arc:function(a,b,c,d,e,f){c<0&&isFinite(c)&&i(1);this.a.push("i",a,b,c,d,e,f?1:0)},fill:function(){this.h(1);this.a.push("j");this.b||this.c();this.d=0},stroke:function(){this.h(6);this.a.push("k");this.b||this.c();this.d=0},clip:function(){this.a.push("l")},isPointInPath:function(a,b){this.a.push("m",a,b);return this.f()==="true"},fillText:function(a,b,c,d){this.h(9);
this.g.push(this.a.length+1);this.a.push("r",a,b,c,d===q?Infinity:d);this.b||this.c();this.d=0},strokeText:function(a,b,c,d){this.h(10);this.g.push(this.a.length+1);this.a.push("s",a,b,c,d===q?Infinity:d);this.b||this.c();this.d=0},measureText:function(a){var b=z[this.e];try{b.style.font=this.font}catch(c){}b.innerText=(""+a).replace(/[ \n\f\r]/g,"\t");return new ha(b.offsetWidth)},drawImage:function(a,b,c,d,e,f,h,ja,l){a||i(17);var g=a.tagName,k,j,m,n=arguments.length,o=this.e;if(g)if(g=g.toLowerCase(),
g==="img")k=a.getAttribute("src",2);else if(g===r)j=this.C(a),m=a!==this.canvas;else if(g==="video")return;else i(17);else a.src?k=a.src:i(17);j||(j=u[o][k],(m=j===q)&&(j=this.k(k)));this.h(0);if(n===3)this.a.push("u",n,j,b,c);else if(n===5)this.a.push("u",n,j,b,c,d,e);else if(n===9)(d===0||e===0)&&i(1),this.a.push("u",n,j,b,c,d,e,f,h,ja,l);else return;m&&s[o]?(this.f(),++p[o]):this.b||this.c();this.d=0},createImageData:function(a,b){var c=Math.ceil;arguments.length===2?((!isFinite(a)||!isFinite(b))&&
i(9),(a===0||b===0)&&i(1)):(a instanceof w||i(9),b=a.height,a=a.width);a=c(a<0?-a:a);b=c(b<0?-b:b);return new w(a,b)},getImageData:function(a,b,c,d){(!isFinite(a)||!isFinite(b)||!isFinite(c)||!isFinite(d))&&i(9);(c===0||d===0)&&i(1);this.a.push("w",a,b,c,d);a=this.f();c=typeof JSON==="object"?JSON.parse(a):k.documentMode?eval(a):a.slice(1,-1).split(",");a=c.shift();b=c.shift();return new w(a,b,c)},putImageData:function(a,b,c,d,e,f,h){a instanceof w||i(17);(!isFinite(b)||!isFinite(c))&&i(9);var g=
arguments.length,j=a.width,k=a.height,l=a.data;g===3?this.a.push("x",g,j,k,l.toString(),b,c):g===7&&((!isFinite(d)||!isFinite(e)||!isFinite(f)||!isFinite(h))&&i(9),this.a.push("x",g,j,k,l.toString(),b,c,d,e,f,h));this.b||this.c();this.d=0},loadFont:function(a,b,c){var d=this.e;if(b||c)v[d][a]=[a,b,c];this.g.push(this.a.length+1);this.a.push("6",a);s[d]?(this.f(),++p[d]):this.b||this.c()},loadImage:function(a,b,c){var d=a.tagName,e,f=this.e;if(d)d.toLowerCase()==="img"&&(e=a.getAttribute("src",2));
else if(a.src)e=a.src;if(e&&u[f][e]===q){d=this.k(e);if(b||c)v[f][d]=[a,b,c];this.a.push("u",1,d);s[f]&&(this.f(),++p[f])}},G:function(){this.globalAlpha=this.m=1;this.globalCompositeOperation=this.n="source-over";this.fillStyle=this.l=this.strokeStyle=this.w="#000000";this.lineWidth=this.q=1;this.lineCap=this.o="butt";this.lineJoin=this.p="miter";this.miterLimit=this.r=10;this.shadowBlur=this.s=this.shadowOffsetY=this.v=this.shadowOffsetX=this.u=0;this.shadowColor=this.t="rgba(0, 0, 0, 0.0)";this.font=
this.j="10px sans-serif";this.textAlign=this.A="start";this.textBaseline=this.B="alphabetic";this.a=[];this.I=[];this.i=[];this.g=[];this.b=g;this.H=1},h:function(a){var b=this.a,c;if(this.m!==this.globalAlpha)b.push("I",this.m=this.globalAlpha);if(this.n!==this.globalCompositeOperation)b.push("J",this.n=this.globalCompositeOperation);if(this.u!==this.shadowOffsetX)b.push("T",this.u=this.shadowOffsetX);if(this.v!==this.shadowOffsetY)b.push("U",this.v=this.shadowOffsetY);if(this.s!==this.shadowBlur)b.push("V",
this.s=this.shadowBlur);if(this.t!==this.shadowColor)c=this.t=this.shadowColor,(""+c).indexOf("%")>0&&this.i.push(b.length+1),b.push("W",c);if(a&1&&this.l!==this.fillStyle)c=this.l=this.fillStyle,typeof c==="string"?(c.indexOf("%")>0&&this.i.push(b.length+1),b.push("L",c)):(c instanceof o||c instanceof x)&&b.push("L",c.id);if(a&2&&this.w!==this.strokeStyle)c=this.w=this.strokeStyle,typeof c==="string"?(c.indexOf("%")>0&&this.i.push(b.length+1),b.push("K",c)):(c instanceof o||c instanceof x)&&b.push("K",
c.id);if(a&4){if(this.q!==this.lineWidth)b.push("P",this.q=this.lineWidth);if(this.o!==this.lineCap)b.push("Q",this.o=this.lineCap);if(this.p!==this.lineJoin)b.push("R",this.p=this.lineJoin);if(this.r!==this.miterLimit)b.push("S",this.r=this.miterLimit)}if(a&8){if(this.j!==this.font)a=z[this.e].offsetHeight,this.g.push(b.length+2),b.push("o",a,this.j=this.font);if(this.A!==this.textAlign)b.push("p",this.A=this.textAlign);if(this.B!==this.textBaseline)b.push("q",this.B=this.textBaseline);if(this.D!==
this.canvas.currentStyle.direction)b.push("1",this.D=this.canvas.currentStyle.direction)}},c:function(){var a=this;a.b=setTimeout(function(){p[a.e]?a.c():(a.b=g,a.f(L))},M)},L:function(){clearTimeout(this.b);this.b=g},f:function(a){var b,c,d,e=this.i,f=this.g,h=this.a,g=this.z;if(h.length){this.b&&this.L();if(a){for(b=0,c=e.length;b<c;++b)d=e[b],h[d]=encodeURI(h[d]);for(b=0,c=f.length;b<c;++b)d=f[b],h[d]=encodeURIComponent(h[d])}else for(b=0,c=f.length;b<c;++b)d=f[b],h[d]=(""+h[d]).replace(/&/g,"&amp;").replace(/</g,
"&lt;");b=h.join("\u0001");this.a=[];this.i=[];this.g=[];if(a)g.flashvars="c="+b,g.width=g.clientWidth+this.H,this.H^=-2;else return g.CallFunction('<invoke name="executeCommand" returntype="javascript"><arguments><string>'+b+"</string></arguments></invoke>")}},K:function(a,b){this.f();this.G();if(a>0)this.z.width=a;if(b>0)this.z.height=b;this.a.push("2",a,b);this.b||this.c();this.d=0},C:function(a){var b=a.getContext("2d").e,c=r+":"+b;(a.width===0||a.height===0)&&i(11);if(b!==this.e&&(a=m[b].getContext("2d"),
!a.d))b=++ba[b],c+=":"+b,a.a.push("3",b),a.b||a.c(),a.d=1;return c},k:function(a){var b=this.e,c=u[b],d=aa[b],e=c[a]=K[b]++;e>=da-1&&(K[b]=0);e in d&&delete c[d[e]];this.g.push(this.a.length+2);this.a.push("5",e,a);d[e]=a;return e}};o.prototype={addColorStop:function(a,b){(isNaN(a)||a<0||a>1)&&i(1);var c=this.J,d=this.id;(""+b).indexOf("%")>0&&c.i.push(c.a.length+3);c.a.push("y",d,a,b)}};O.prototype=Error();var ga={1:"INDEX_SIZE_ERR",9:"NOT_SUPPORTED_ERR",11:"INVALID_STATE_ERR",12:"SYNTAX_ERR",17:"TYPE_MISMATCH_ERR",
18:"SECURITY_ERR"},C={initElement:function(a){if(a.getContext)return a;var b=Math.random().toString(36).slice(2)||"0",c="external"+b;s[b]=0;u[b]={};aa[b]=[];K[b]=0;p[b]=1;ba[b]=0;v[b]=[];$(a);a.innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+location.protocol+'//fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="'+c+'"><param name="allowScriptAccess" value="always"><param name="flashvars" value="id='+c+
'"><param name="wmode" value="transparent"></object><span style="margin:0;padding:0;border:0;display:inline-block;position:static;height:1em;overflow:visible;white-space:nowrap"></span>';m[b]=a;var d=a.firstChild;z[b]=a.lastChild;var e=k.body.contains;if(e(a))d.movie=t;else var f=setInterval(function(){if(e(a))clearInterval(f),d.movie=t},0);if(k.compatMode==="BackCompat"||!l.XMLHttpRequest)z[b].style.overflow="hidden";var h=new A(a,d);a.getContext=function(a){return a==="2d"?h:g};a.toDataURL=function(b,
c){if(a.width===0||a.height===0)return"data:,";(""+b).replace(/[A-Z]+/g,ia)==="image/jpeg"?h.a.push("A",b,typeof c==="number"?c:""):h.a.push("A",b);return h.f().slice(1,-1)};d.attachEvent(U,Q);ca&&(d.attachEvent(F,D),a.attachEvent(G,E));N&&h.a.push(y,"usePolicyFile",N);b=h.a.length;h.g.push(b+2,b+5);h.a.push(y,"proxy",ea,y,"save",fa);return a},saveImage:function(a,b){a.firstChild.saveImage(b)},setOptions:function(a){for(var b in a){var c=a[b];switch(b){case "turbo":L=c;break;case "delay":M=c;break;
case "disableContextMenu":ca=c;var d=void 0;for(d in m){var e=m[d],f=c?"attachEvent":"detachEvent";e.firstChild[f](F,D);e[f](G,E)}break;case "imageCacheSize":da=c;break;case "usePolicyFile":I(b,N=c?1:0);break;case "proxy":I(b,ea=c);break;case "save":I(b,fa=c)}}},trigger:function(a,b){m[a].fireEvent("on"+b)},unlock:function(a,b,c){var d,e,f;p[a]&&--p[a];if(b===q){d=m[a];b=d.firstChild;$(d);e=d.width;c=d.height;d.style.width=e+"px";d.style.height=c+"px";if(e>0)b.width=e;if(c>0)b.height=c;b.resize(e,
c);d.attachEvent(V,R);s[a]=1;typeof d.onload==="function"&&setTimeout(function(){d.onload()},0)}else if(f=v[a][b])e=f[0],c=f[1+c],delete v[a][b],typeof c==="function"&&c.call(e)}};k.createElement(r);k.createStyleSheet().cssText=r+"{display:inline-block;overflow:hidden;width:300px;height:150px}";J&&(k.readyState==="complete"?B():k.attachEvent(P,B));l.attachEvent(T,S);t.indexOf(location.protocol+"//"+location.host+"/")===0&&(n=new ActiveXObject("Microsoft.XMLHTTP"),n.open("GET",t,!1),n.send(g));l[W]=
A;l[X]=o;l[Y]=x;l[H]=C;l[Z]={init:function(){},init_:function(){},initElement:C.initElement}}(window,document);
(function(document){
webshims.addReady(function(context, elem){
if(context == document){
if(window.G_vmlCanvasManager && G_vmlCanvasManager.init_ ){
G_vmlCanvasManager.init_(document);
}
}
webshims.$('canvas', context).add(elem.filter('canvas')).each(function(){
var hasContext = this.getContext;
if(!hasContext && window.G_vmlCanvasManager){
G_vmlCanvasManager.initElement(this);
}
});
});
webshims.isReady('canvas', true);
})(document);

View File

@ -0,0 +1,94 @@
<?php
/**
* Proxy script to load a file from other domain
*
* PHP versions 4 and 5
*
* Copyright (c) 2010-2013 Shinya Muramatsu
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Shinya Muramatsu <revulon@gmail.com>
* @copyright 2010-2013 Shinya Muramatsu
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @link http://flashcanvas.net/
* @link http://code.google.com/p/flashcanvas/
*/
function getHostName() {
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
return $_SERVER['HTTP_X_FORWARDED_HOST'];
} else if (isset($_SERVER['HTTP_HOST'])) {
return $_SERVER['HTTP_HOST'];
} else {
return $_SERVER['SERVER_NAME'];
}
}
// Whether we check referrer or not
define('CHECK_REFERRER', true);
// If necessary, specify the host where the SWF file is located
define('SWF_HOST_NAME', '');
// Check that the request comes from the same host
if (CHECK_REFERRER) {
if (empty($_SERVER['HTTP_REFERER'])) {
exit;
}
if (SWF_HOST_NAME) {
$host = SWF_HOST_NAME;
} else {
$host = getHostName();
}
$pattern = '#^https?://' . str_replace('.', '\.', $host) . '(:\d*)?/#';
if (!preg_match($pattern, $_SERVER['HTTP_REFERER'])) {
exit;
}
}
// Check that the request has a valid URL parameter
if (empty($_GET['url'])) {
exit;
}
if (!preg_match('#^https?://#', $_GET['url'])) {
exit;
}
// Percent-encode special characters in the URL
$search = array( '%', '#', ' ');
$replace = array('%25', '%23', '%20');
$url = str_replace($search, $replace, $_GET['url']);
// Disable compression
header('Content-Encoding: none');
// Load and output the file
if (extension_loaded('curl')) {
// Use cURL extension
$ch = curl_init($url);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_exec($ch);
curl_close($ch);
} else {
// Use the http:// wrapper
readfile($url);
}

View File

@ -0,0 +1,55 @@
<?php
/**
* Save the input as a PNG file
*
* PHP versions 4 and 5
*
* Copyright (c) 2010-2013 Shinya Muramatsu
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* @author Shinya Muramatsu <revulon@gmail.com>
* @copyright 2010-2013 Shinya Muramatsu
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* @link http://flashcanvas.net/
* @link http://code.google.com/p/flashcanvas/
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_GET['filename'])) {
$filename = $_GET['filename'];
} else {
$filename = 'canvas.png';
}
// Force download
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $filename . '"');
if (isset($_POST['dataurl'])) {
// Decode the base64-encoded data
$data = $_POST['dataurl'];
$data = substr($data, strpos($data, ',') + 1);
echo base64_decode($data);
} else {
// Output the raw data
readfile('php://input');
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,739 @@
(function(){
"use strict";
try {
new Image();
} catch(e){
window.Image = function(){
return document.createElement('img');
};
}
webshim.isReady('picture', true);
setTimeout(function(){
webshim.ready('matchMedia', function(){
if(window.picturefill){
var sel = 'picture, img[srcset]';
webshim.addReady(function(context){
if(context.querySelector(sel)){
window.picturefill();
}
});
}
});
});
})();
/*! Picturefill - v2.1.0-beta - 2014-06-03
* http://scottjehl.github.io/picturefill
* Copyright (c) 2014 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT */
/*! Picturefill - Responsive Images that work today.
* Author: Scott Jehl, Filament Group, 2012 ( new proposal implemented by Shawn Jansepar )
* License: MIT/GPLv2
* Spec: http://picture.responsiveimages.org/
*/
(function( w, doc ) {
// Enable strict mode
"use strict";
// If picture is supported, well, that's awesome. Let's get outta here...
if ( w.HTMLPictureElement ) {
return;
}
// HTML shim|v it for old IE (IE9 will still need the HTML video tag workaround)
doc.createElement( "picture" );
// local object for method references and testing exposure
var pf = {};
// namespace
pf.ns = "picturefill";
// srcset support test
pf.srcsetSupported = new w.Image().srcset !== undefined;
// just a string trim workaround
pf.trim = function( str ) {
return str.trim ? str.trim() : str.replace( /^\s+|\s+$/g, "" );
};
// just a string endsWith workaround
pf.endsWith = function( str, suffix ) {
return str.endsWith ? str.endsWith( suffix ) : str.indexOf( suffix, str.length - suffix.length ) !== -1;
};
/**
* Shortcut method for matchMedia ( for easy overriding in tests )
*/
pf.matchesMedia = function( media ) {
return w.matchMedia && w.matchMedia( media ).matches;
};
/**
* Shortcut method for `devicePixelRatio` ( for easy overriding in tests )
*/
pf.getDpr = function() {
return ( w.devicePixelRatio || 1 );
};
/**
* Get width in css pixel value from a "length" value
* http://dev.w3.org/csswg/css-values-3/#length-value
*/
pf.getWidthFromLength = function( length ) {
// If no length was specified, or it is 0, default to `100vw` (per the spec).
length = length && parseFloat( length ) > 0 ? length : "100vw";
/**
* If length is specified in `vw` units, use `%` instead since the div were measuring
* is injected at the top of the document.
*
* TODO: maybe we should put this behind a feature test for `vw`?
*/
length = length.replace( "vw", "%" );
// Create a cached element for getting length value widths
if ( !pf.lengthEl ) {
pf.lengthEl = doc.createElement( "div" );
doc.documentElement.insertBefore( pf.lengthEl, doc.documentElement.firstChild );
}
// Positioning styles help prevent padding/margin/width on `html` from throwing calculations off.
pf.lengthEl.style.cssText = "position: absolute; left: 0; width: " + length + ";";
// Using offsetWidth to get width from CSS
return pf.lengthEl.offsetWidth;
};
// container of supported mime types that one might need to qualify before using
pf.types = {};
// Add support for standard mime types.
pf.types["image/jpeg"] = true;
pf.types["image/gif"] = true;
pf.types["image/png"] = true;
// test svg support
pf.types[ "image/svg+xml" ] = doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1");
// test webp support, only when the markup calls for it
pf.types[ "image/webp" ] = function() {
// based on Modernizr's lossless img-webp test
// note: asynchronous
var img = new w.Image(),
type = "image/webp";
img.onerror = function() {
pf.types[ type ] = false;
picturefill();
};
img.onload = function() {
pf.types[ type ] = img.width === 1;
picturefill();
};
img.src = "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";
};
/**
* Takes a source element and checks if its type attribute is present and if so, supported
* Note: for type tests that require a async logic,
* you can define them as a function that'll run only if that type needs to be tested. Just make the test function call picturefill again when it is complete.
* see the async webp test above for example
*/
pf.verifyTypeSupport = function( source ) {
var type = source.getAttribute( "type" );
// if type attribute exists, return test result, otherwise return true
if ( type === null || type === "" ) {
return true;
} else {
// if the type test is a function, run it and return "pending" status. The function will rerun picturefill on pending elements once finished.
if ( typeof( pf.types[ type ] ) === "function" ) {
pf.types[ type ]();
return "pending";
} else {
return pf.types[ type ];
}
}
};
/**
* Parses an individual `size` and returns the length, and optional media query
*/
pf.parseSize = function( sourceSizeStr ) {
var match = /(\([^)]+\))?\s*(.+)/g.exec( sourceSizeStr );
return {
media: match && match[1],
length: match && match[2]
};
};
/**
* Takes a string of sizes and returns the width in pixels as a number
*/
pf.findWidthFromSourceSize = function( sourceSizeListStr ) {
// Split up source size list, ie ( max-width: 30em ) 100%, ( max-width: 50em ) 50%, 33%
// or (min-width:30em) calc(30% - 15px)
var sourceSizeList = pf.trim( sourceSizeListStr ).split( /\s*,\s*/ ),
winningLength;
for ( var i = 0, len = sourceSizeList.length; i < len; i++ ) {
// Match <media-condition>? length, ie ( min-width: 50em ) 100%
var sourceSize = sourceSizeList[ i ],
// Split "( min-width: 50em ) 100%" into separate strings
parsedSize = pf.parseSize( sourceSize ),
length = parsedSize.length,
media = parsedSize.media;
if ( !length ) {
continue;
}
if ( !media || pf.matchesMedia( media ) ) {
// if there is no media query or it matches, choose this as our winning length
// and end algorithm
winningLength = length;
break;
}
}
// pass the length to a method that can properly determine length
// in pixels based on these formats: http://dev.w3.org/csswg/css-values-3/#length-value
return pf.getWidthFromLength( winningLength );
};
pf.parseSrcset = function( srcset ) {
/**
* A lot of this was pulled from Boris Smus parser for the now-defunct WHATWG `srcset`
* https://github.com/borismus/srcset-polyfill/blob/master/js/srcset-info.js
*
* 1. Let input (`srcset`) be the value passed to this algorithm.
* 2. Let position be a pointer into input, initially pointing at the start of the string.
* 3. Let raw candidates be an initially empty ordered list of URLs with associated
* unparsed descriptors. The order of entries in the list is the order in which entries
* are added to the list.
*/
var candidates = [];
while ( srcset !== "" ) {
srcset = srcset.replace(/^\s+/g,"");
// 5. Collect a sequence of characters that are not space characters, and let that be url.
var pos = srcset.search(/\s/g),
url, descriptor = null;
if ( pos !== -1 ) {
url = srcset.slice( 0, pos );
var last = url[ url.length - 1 ];
// 6. If url ends with a U+002C COMMA character (,), remove that character from url
// and let descriptors be the empty string. Otherwise, follow these substeps
// 6.1. If url is empty, then jump to the step labeled descriptor parser.
if ( last === "," || url === "" ) {
url = url.replace(/,+$/, "");
descriptor = "";
}
srcset = srcset.slice( pos + 1 );
// 6.2. Collect a sequence of characters that are not U+002C COMMA characters (,), and
// let that be descriptors.
if ( descriptor === null ) {
var descpos = srcset.indexOf(",");
if ( descpos !== -1 ) {
descriptor = srcset.slice( 0, descpos );
srcset = srcset.slice( descpos + 1 );
} else {
descriptor = srcset;
srcset = "";
}
}
} else {
url = srcset;
srcset = "";
}
// 7. Add url to raw candidates, associated with descriptors.
if ( url || descriptor ) {
candidates.push({
url: url,
descriptor: descriptor
});
}
}
return candidates;
};
pf.parseDescriptor = function( descriptor, sizes ) {
// 11. Descriptor parser: Let candidates be an initially empty source set. The order of entries in the list
// is the order in which entries are added to the list.
var sizeDescriptor = descriptor && descriptor.replace(/(^\s+|\s+$)/g, ""),
widthInCssPixels = sizes ? pf.findWidthFromSourceSize( sizes ) : "100%",
resCandidate;
if ( sizeDescriptor ) {
var splitDescriptor = sizeDescriptor.split(" ");
for (var i = splitDescriptor.length + 1; i >= 0; i--) {
var curr = splitDescriptor[ i ],
lastchar = curr && curr.slice( curr.length - 1 );
if ( lastchar === "w" || lastchar === "x" ) {
resCandidate = curr;
}
if ( sizes && resCandidate ) {
// get the dpr by taking the length / width in css pixels
resCandidate = parseFloat( ( parseInt( curr, 10 ) / widthInCssPixels ) );
} else {
// get the dpr by grabbing the value of Nx
var res = curr && parseFloat( curr, 10 );
resCandidate = res && !isNaN( res ) && lastchar === "x" || lastchar === "w" ? res : 1;
}
}
} else {
resCandidate = 1;
}
return resCandidate;
};
/**
* Takes a srcset in the form of url/
* ex. "images/pic-medium.png 1x, images/pic-medium-2x.png 2x" or
* "images/pic-medium.png 400w, images/pic-medium-2x.png 800w" or
* "images/pic-small.png"
* Get an array of image candidates in the form of
* {url: "/foo/bar.png", resolution: 1}
* where resolution is http://dev.w3.org/csswg/css-values-3/#resolution-value
* If sizes is specified, resolution is calculated
*/
pf.getCandidatesFromSourceSet = function( srcset, sizes ) {
var candidates = pf.parseSrcset( srcset ),
formattedCandidates = [];
for ( var i = 0, len = candidates.length; i < len; i++ ) {
var candidate = candidates[ i ];
formattedCandidates.push({
url: candidate.url,
resolution: pf.parseDescriptor( candidate.descriptor, sizes )
});
}
return formattedCandidates;
};
/*
* if it's an img element and it has a srcset property,
* we need to remove the attribute so we can manipulate src
* (the property's existence infers native srcset support, and a srcset-supporting browser will prioritize srcset's value over our winning picture candidate)
* this moves srcset's value to memory for later use and removes the attr
*/
pf.dodgeSrcset = function( img ) {
if ( img.srcset ) {
img[ pf.ns ].srcset = img.srcset;
img.removeAttribute( "srcset" );
}
};
/*
* Accept a source or img element and process its srcset and sizes attrs
*/
pf.processSourceSet = function( el ) {
var srcset = el.getAttribute( "srcset" ),
sizes = el.getAttribute( "sizes" ),
candidates = [];
// if it's an img element, use the cached srcset property (defined or not)
if ( el.nodeName.toUpperCase() === "IMG" && el[ pf.ns ] && el[ pf.ns ].srcset ) {
srcset = el[ pf.ns ].srcset;
}
if ( srcset ) {
candidates = pf.getCandidatesFromSourceSet( srcset, sizes );
}
return candidates;
};
pf.applyBestCandidate = function( candidates, picImg ) {
var candidate,
length,
bestCandidate;
candidates.sort( pf.ascendingSort );
length = candidates.length;
bestCandidate = candidates[ length - 1 ];
for ( var i = 0; i < length; i++ ) {
candidate = candidates[ i ];
if ( candidate.resolution >= pf.getDpr() ) {
bestCandidate = candidate;
break;
}
}
if ( !pf.endsWith( picImg.src, bestCandidate.url ) ) {
picImg.src = bestCandidate.url;
// currentSrc attribute and property to match
// http://picture.responsiveimages.org/#the-img-element
picImg.currentSrc = picImg.src;
}
};
pf.ascendingSort = function( a, b ) {
return a.resolution - b.resolution;
};
/*
* In IE9, <source> elements get removed if they aren't children of
* video elements. Thus, we conditionally wrap source elements
* using <!--[if IE 9]><video style="display: none;"><![endif]-->
* and must account for that here by moving those source elements
* back into the picture element.
*/
pf.removeVideoShim = function( picture ) {
var videos = picture.getElementsByTagName( "video" );
if ( videos.length ) {
var video = videos[ 0 ],
vsources = video.getElementsByTagName( "source" );
while ( vsources.length ) {
picture.insertBefore( vsources[ 0 ], video );
}
// Remove the video element once we're finished removing its children
video.parentNode.removeChild( video );
}
};
/*
* Find all picture elements and,
* in browsers that don't natively support srcset, find all img elements
* with srcset attrs that don't have picture parents
*/
pf.getAllElements = function() {
var pictures = doc.getElementsByTagName( "picture" ),
elems = [],
imgs = doc.getElementsByTagName( "img" );
for ( var h = 0, len = pictures.length + imgs.length; h < len; h++ ) {
if ( h < pictures.length ) {
elems[ h ] = pictures[ h ];
} else {
var currImg = imgs[ h - pictures.length ];
if ( currImg.parentNode.nodeName.toUpperCase() !== "PICTURE" &&
( ( pf.srcsetSupported && currImg.getAttribute( "sizes" ) ) ||
currImg.getAttribute( "srcset" ) !== null ) ) {
elems.push( currImg );
}
}
}
return elems;
};
pf.getMatch = function( picture ) {
var sources = picture.childNodes,
match;
// Go through each child, and if they have media queries, evaluate them
for ( var j = 0, slen = sources.length; j < slen; j++ ) {
var source = sources[ j ];
// ignore non-element nodes
if ( source.nodeType !== 1 ) {
continue;
}
// Hitting an `img` element stops the search for `sources`.
// If no previous `source` matches, the `img` itself is evaluated later.
if ( source.nodeName.toUpperCase() === "IMG" ) {
return match;
}
// ignore non-`source` nodes
if ( source.nodeName.toUpperCase() !== "SOURCE" ) {
continue;
}
var media = source.getAttribute( "media" );
// if source does not have a srcset attribute, skip
if ( !source.getAttribute( "srcset" ) ) {
continue;
}
// if there's no media specified, OR w.matchMedia is supported
if ( ( !media || pf.matchesMedia( media ) ) ) {
var typeSupported = pf.verifyTypeSupport( source );
if ( typeSupported === true ) {
match = source;
break;
} else if ( typeSupported === "pending" ) {
return false;
}
}
}
return match;
};
function picturefill( options ) {
var elements,
element,
elemType,
firstMatch,
candidates,
picImg;
options = options || {};
elements = options.elements || pf.getAllElements();
// Loop through all elements
for ( var i = 0, plen = elements.length; i < plen; i++ ) {
element = elements[ i ];
elemType = element.nodeName.toUpperCase();
firstMatch = undefined;
candidates = undefined;
picImg = undefined;
// expando for caching data on the img
if ( !element[ pf.ns ] ) {
element[ pf.ns ] = {};
}
// if the element has already been evaluated, skip it
// unless `options.force` is set to true ( this, for example,
// is set to true when running `picturefill` on `resize` ).
if ( !options.reevaluate && element[ pf.ns ].evaluated ) {
continue;
}
// if element is a picture element
if ( elemType === "PICTURE" ) {
// IE9 video workaround
pf.removeVideoShim( element );
// return the first match which might undefined
// returns false if there is a pending source
// TODO the return type here is brutal, cleanup
firstMatch = pf.getMatch( element );
// if any sources are pending in this picture due to async type test(s)
// remove the evaluated attr and skip for now ( the pending test will
// rerun picturefill on this element when complete)
if ( firstMatch === false ) {
continue;
}
// Find any existing img element in the picture element
picImg = element.getElementsByTagName( "img" )[ 0 ];
} else {
// if it's an img element
firstMatch = undefined;
picImg = element;
}
if ( picImg ) {
// expando for caching data on the img
if ( !picImg[ pf.ns ] ) {
picImg[ pf.ns ] = {};
}
// Cache and remove `srcset` if present and were going to be doing `sizes`/`picture` polyfilling to it.
if ( picImg.srcset && ( elemType === "PICTURE" || picImg.getAttribute( "sizes" ) ) ) {
pf.dodgeSrcset( picImg );
}
if ( firstMatch ) {
candidates = pf.processSourceSet( firstMatch );
pf.applyBestCandidate( candidates, picImg );
} else {
// No sources matched, so were down to processing the inner `img` as a source.
candidates = pf.processSourceSet( picImg );
if ( picImg.srcset === undefined || picImg[ pf.ns ].srcset ) {
// Either `srcset` is completely unsupported, or we need to polyfill `sizes` functionality.
pf.applyBestCandidate( candidates, picImg );
} // Else, resolution-only `srcset` is supported natively.
}
// set evaluated to true to avoid unnecessary reparsing
element[ pf.ns ].evaluated = true;
}
}
}
/**
* Sets up picture polyfill by polling the document and running
* the polyfill every 250ms until the document is ready.
* Also attaches picturefill on resize
*/
function runPicturefill() {
picturefill();
var intervalId = setInterval( function() {
// When the document has finished loading, stop checking for new images
// https://github.com/ded/domready/blob/master/ready.js#L15
picturefill();
if ( /^loaded|^i|^c/.test( doc.readyState ) ) {
clearInterval( intervalId );
return;
}
}, 250 );
if ( w.addEventListener ) {
var resizeThrottle;
w.addEventListener( "resize", function() {
if (!w._picturefillWorking) {
w._picturefillWorking = true;
w.clearTimeout( resizeThrottle );
resizeThrottle = w.setTimeout( function() {
picturefill({ reevaluate: true });
w._picturefillWorking = false;
}, 60 );
}
}, false );
}
}
webshim.ready('matchMedia', runPicturefill);
/* expose methods for testing */
picturefill._ = pf;
/* expose picturefill */
if ( typeof module === "object" && typeof module.exports === "object" ) {
// CommonJS, just export
module.exports = picturefill;
} else if ( typeof define === "function" && define.amd ){
// AMD support
define( function() { return picturefill; } );
} else if ( typeof w === "object" ) {
// If no AMD and we are in the browser, attach to window
w.picturefill = picturefill;
}
} )( this, this.document );
;/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
window.matchMedia || (window.matchMedia = function() {
"use strict";
// For browsers that support matchMedium api such as IE 9 and webkit
var styleMedia = (window.styleMedia || window.media);
// For those that don't support matchMedium
if (!styleMedia) {
var style = document.createElement('style'),
script = document.getElementsByTagName('script')[0],
info = null;
style.type = 'text/css';
style.id = 'matchmediajs-test';
script.parentNode.insertBefore(style, script);
// 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
styleMedia = {
matchMedium: function(media) {
var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
// 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
if (style.styleSheet) {
style.styleSheet.cssText = text;
} else {
style.textContent = text;
}
// Test if media query is true or false
return info.width === '1px';
}
};
}
return function(media) {
return {
matches: styleMedia.matchMedium(media || 'all'),
media: media || 'all'
};
};
}());
/*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license */
(function(){
// Bail out for browsers that have addListener support
if (window.matchMedia && window.matchMedia('all').addListener) {
return false;
}
var localMatchMedia = window.matchMedia,
hasMediaQueries = localMatchMedia('only all').matches,
isListening = false,
timeoutID = 0, // setTimeout for debouncing 'handleChange'
queries = [], // Contains each 'mql' and associated 'listeners' if 'addListener' is used
handleChange = function(evt) {
// Debounce
clearTimeout(timeoutID);
timeoutID = setTimeout(function() {
for (var i = 0, il = queries.length; i < il; i++) {
var mql = queries[i].mql,
listeners = queries[i].listeners || [],
matches = localMatchMedia(mql.media).matches;
// Update mql.matches value and call listeners
// Fire listeners only if transitioning to or from matched state
if (matches !== mql.matches) {
mql.matches = matches;
for (var j = 0, jl = listeners.length; j < jl; j++) {
listeners[j].call(window, mql);
}
}
}
}, 30);
};
window.matchMedia = function(media) {
var mql = localMatchMedia(media),
listeners = [],
index = 0;
mql.addListener = function(listener) {
// Changes would not occur to css media type so return now (Affects IE <= 8)
if (!hasMediaQueries) {
return;
}
// Set up 'resize' listener for browsers that support CSS3 media queries (Not for IE <= 8)
// There should only ever be 1 resize listener running for performance
if (!isListening) {
isListening = true;
window.addEventListener('resize', handleChange, true);
}
// Push object only if it has not been pushed already
if (index === 0) {
index = queries.push({
mql : mql,
listeners : listeners
});
}
listeners.push(listener);
};
mql.removeListener = function(listener) {
for (var i = 0, il = listeners.length; i < il; i++){
if (listeners[i] === listener){
listeners.splice(i, 1);
}
}
};
return mql;
};
}());
webshim.isReady('matchMedia', true);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,759 @@
/*! SWFMini - a SWFObject 2.2 cut down version for webshims
*
* based on SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfmini = function() {
var wasRemoved = function(){webshims.error('This method was removed from swfmini');};
var UNDEF = "undefined",
OBJECT = "object",
webshims = window.webshims,
SHOCKWAVE_FLASH = "Shockwave Flash",
SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
FLASH_MIME_TYPE = "application/x-shockwave-flash",
win = window,
doc = document,
nav = navigator,
plugin = false,
domLoadFnArr = [main],
isDomLoaded = false,
autoHideShow = true,
/* Centralized function for browser feature detection
- User agent string detection is only used when no good alternative is possible
- Is executed directly for optimal performance
*/
ua = function() {
var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
u = nav.userAgent.toLowerCase(),
p = nav.platform.toLowerCase(),
windows = p ? /win/.test(p) : /win/.test(u),
mac = p ? /mac/.test(p) : /mac/.test(u),
webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
playerVersion = [0,0,0],
d = null;
if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
d = nav.plugins[SHOCKWAVE_FLASH].description;
if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
plugin = true;
ie = false; // cascaded feature detection for Internet Explorer
d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
}
}
else if (typeof win.ActiveXObject != UNDEF) {
try {
var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
if (a) { // a will return null when ActiveX is disabled
d = a.GetVariable("$version");
if (d) {
ie = true; // cascaded feature detection for Internet Explorer
d = d.split(" ")[1].split(",");
playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
}
catch(e) {}
}
return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
}();
function callDomLoadFunctions() {
if (isDomLoaded) { return; }
isDomLoaded = true;
var dl = domLoadFnArr.length;
for (var i = 0; i < dl; i++) {
domLoadFnArr[i]();
}
}
function addDomLoadEvent(fn) {
if (isDomLoaded) {
fn();
}
else {
domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
}
}
/* Main function
- Will preferably execute onDomLoad, otherwise onload (as a fallback)
*/
function main() {
if (plugin) {
testPlayerVersion();
}
}
/* Detect the Flash Player version for non-Internet Explorer browsers
- Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
a. Both release and build numbers can be detected
b. Avoid wrong descriptions by corrupt installers provided by Adobe
c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
- Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
*/
function testPlayerVersion() {
var b = doc.getElementsByTagName("body")[0];
var o = createElement(OBJECT);
o.setAttribute("type", FLASH_MIME_TYPE);
var t = b.appendChild(o);
if (t) {
var counter = 0;
(function(){
if (typeof t.GetVariable != UNDEF) {
var d = t.GetVariable("$version");
if (d) {
d = d.split(" ")[1].split(",");
ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
}
}
else if (counter < 10) {
counter++;
setTimeout(arguments.callee, 10);
return;
}
b.removeChild(o);
t = null;
})();
}
}
function createElement(el) {
return doc.createElement(el);
}
/* Flash Player and SWF content version matching
*/
function hasPlayerVersion(rv) {
var pv = ua.pv, v = rv.split(".");
v[0] = parseInt(v[0], 10);
v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
v[2] = parseInt(v[2], 10) || 0;
return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
}
webshims.ready('DOM', callDomLoadFunctions);
webshims.loader.addModule('swfmini-embed', {d: ['swfmini']});
var loadEmbed = hasPlayerVersion('9.0.0') ?
function(){
webshims.loader.loadList(['swfmini-embed']);
return true;
} :
webshims.$.noop
;
if(!webshims.support.mediaelement){
loadEmbed();
} else {
webshims.ready('WINDOWLOAD', loadEmbed);
}
return {
/* Public API
- Reference: http://code.google.com/p/swfobject/wiki/documentation
*/
registerObject: wasRemoved,
getObjectById: wasRemoved,
embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
var args = arguments;
if(loadEmbed()){
webshims.ready('swfmini-embed', function(){
swfmini.embedSWF.apply(swfmini, args);
});
} else if(callbackFn) {
callbackFn({success:false, id:replaceElemIdStr});
}
},
switchOffAutoHideShow: function() {
autoHideShow = false;
},
ua: ua,
getFlashPlayerVersion: function() {
return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
},
hasFlashPlayerVersion: hasPlayerVersion,
createSWF: function(attObj, parObj, replaceElemIdStr) {
if (ua.w3) {
return createSWF(attObj, parObj, replaceElemIdStr);
}
else {
return undefined;
}
},
showExpressInstall: wasRemoved,
removeSWF: wasRemoved,
createCSS: wasRemoved,
addDomLoadEvent: addDomLoadEvent,
addLoadEvent: wasRemoved,
// For internal usage only
expressInstallCallback: wasRemoved
};
}();
webshims.isReady('swfmini', true);
;(function(webshims){
"use strict";
var support = webshims.support;
var hasNative = support.mediaelement;
var supportsLoop = false;
var bugs = webshims.bugs;
var swfType = 'mediaelement-jaris';
var loadSwf = function(){
webshims.ready(swfType, function(){
if(!webshims.mediaelement.createSWF){
webshims.mediaelement.loadSwf = true;
webshims.reTest([swfType], hasNative);
}
});
};
var wsCfg = webshims.cfg;
var options = wsCfg.mediaelement;
var isIE = navigator.userAgent.indexOf('MSIE') != -1;
if(!options){
webshims.error("mediaelement wasn't implemented but loaded");
return;
}
if(hasNative){
var videoElem = document.createElement('video');
support.videoBuffered = ('buffered' in videoElem);
support.mediaDefaultMuted = ('defaultMuted' in videoElem);
supportsLoop = ('loop' in videoElem);
support.mediaLoop = supportsLoop;
webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
if( !support.videoBuffered || !supportsLoop || (!support.mediaDefaultMuted && isIE && 'ActiveXObject' in window) ){
webshims.addPolyfill('mediaelement-native-fix', {
d: ['dom-support']
});
webshims.loader.loadList(['mediaelement-native-fix']);
}
}
if(support.track && !bugs.track){
(function(){
if(!bugs.track){
if(window.VTTCue && !window.TextTrackCue){
window.TextTrackCue = window.VTTCue;
} else if(!window.VTTCue){
window.VTTCue = window.TextTrackCue;
}
try {
new VTTCue(2, 3, '');
} catch(e){
bugs.track = true;
}
}
})();
}
webshims.register('mediaelement-core', function($, webshims, window, document, undefined, options){
var hasSwf = swfmini.hasFlashPlayerVersion('10.0.3');
var mediaelement = webshims.mediaelement;
mediaelement.parseRtmp = function(data){
var src = data.src.split('://');
var paths = src[1].split('/');
var i, len, found;
data.server = src[0]+'://'+paths[0]+'/';
data.streamId = [];
for(i = 1, len = paths.length; i < len; i++){
if(!found && paths[i].indexOf(':') !== -1){
paths[i] = paths[i].split(':')[1];
found = true;
}
if(!found){
data.server += paths[i]+'/';
} else {
data.streamId.push(paths[i]);
}
}
if(!data.streamId.length){
webshims.error('Could not parse rtmp url');
}
data.streamId = data.streamId.join('/');
};
var getSrcObj = function(elem, nodeName){
elem = $(elem);
var src = {src: elem.attr('src') || '', elem: elem, srcProp: elem.prop('src')};
var tmp;
if(!src.src){return src;}
tmp = elem.attr('data-server');
if(tmp != null){
src.server = tmp;
}
tmp = elem.attr('type') || elem.attr('data-type');
if(tmp){
src.type = tmp;
src.container = $.trim(tmp.split(';')[0]);
} else {
if(!nodeName){
nodeName = elem[0].nodeName.toLowerCase();
if(nodeName == 'source'){
nodeName = (elem.closest('video, audio')[0] || {nodeName: 'video'}).nodeName.toLowerCase();
}
}
if(src.server){
src.type = nodeName+'/rtmp';
src.container = nodeName+'/rtmp';
} else {
tmp = mediaelement.getTypeForSrc( src.src, nodeName, src );
if(tmp){
src.type = tmp;
src.container = tmp;
}
}
}
tmp = elem.attr('media');
if(tmp){
src.media = tmp;
}
if(src.type == 'audio/rtmp' || src.type == 'video/rtmp'){
if(src.server){
src.streamId = src.src;
} else {
mediaelement.parseRtmp(src);
}
}
return src;
};
var hasYt = !hasSwf && ('postMessage' in window) && hasNative;
var loadTrackUi = function(){
if(loadTrackUi.loaded){return;}
loadTrackUi.loaded = true;
if(!options.noAutoTrack){
webshims.ready('WINDOWLOAD', function(){
loadThird();
webshims.loader.loadList(['track-ui']);
});
}
};
var loadYt = (function(){
var loaded;
return function(){
if(loaded || !hasYt){return;}
loaded = true;
webshims.loader.loadScript("https://www.youtube.com/player_api");
$(function(){
webshims._polyfill(["mediaelement-yt"]);
});
};
})();
var loadThird = function(){
if(hasSwf){
loadSwf();
} else {
loadYt();
}
};
webshims.addPolyfill('mediaelement-yt', {
test: !hasYt,
d: ['dom-support']
});
mediaelement.mimeTypes = {
audio: {
//ogm shouldn´t be used!
'audio/ogg': ['ogg','oga', 'ogm'],
'audio/ogg;codecs="opus"': 'opus',
'audio/mpeg': ['mp2','mp3','mpga','mpega'],
'audio/mp4': ['mp4','mpg4', 'm4r', 'm4a', 'm4p', 'm4b', 'aac'],
'audio/wav': ['wav'],
'audio/3gpp': ['3gp','3gpp'],
'audio/webm': ['webm'],
'audio/fla': ['flv', 'f4a', 'fla'],
'application/x-mpegURL': ['m3u8', 'm3u']
},
video: {
//ogm shouldn´t be used!
'video/ogg': ['ogg','ogv', 'ogm'],
'video/mpeg': ['mpg','mpeg','mpe'],
'video/mp4': ['mp4','mpg4', 'm4v'],
'video/quicktime': ['mov','qt'],
'video/x-msvideo': ['avi'],
'video/x-ms-asf': ['asf', 'asx'],
'video/flv': ['flv', 'f4v'],
'video/3gpp': ['3gp','3gpp'],
'video/webm': ['webm'],
'application/x-mpegURL': ['m3u8', 'm3u'],
'video/MP2T': ['ts']
}
}
;
mediaelement.mimeTypes.source = $.extend({}, mediaelement.mimeTypes.audio, mediaelement.mimeTypes.video);
mediaelement.getTypeForSrc = function(src, nodeName){
if(src.indexOf('youtube.com/watch?') != -1 || src.indexOf('youtube.com/v/') != -1){
return 'video/youtube';
}
if(src.indexOf('rtmp') === 0){
return nodeName+'/rtmp';
}
src = src.split('?')[0].split('#')[0].split('.');
src = src[src.length - 1];
var mt;
$.each(mediaelement.mimeTypes[nodeName], function(mimeType, exts){
if(exts.indexOf(src) !== -1){
mt = mimeType;
return false;
}
});
return mt;
};
mediaelement.srces = function(mediaElem, srces){
mediaElem = $(mediaElem);
if(!srces){
srces = [];
var nodeName = mediaElem[0].nodeName.toLowerCase();
var src = getSrcObj(mediaElem, nodeName);
if(!src.src){
$('source', mediaElem).each(function(){
src = getSrcObj(this, nodeName);
if(src.src){srces.push(src);}
});
} else {
srces.push(src);
}
return srces;
} else {
webshims.error('setting sources was removed.');
}
};
mediaelement.swfMimeTypes = ['video/3gpp', 'video/x-msvideo', 'video/quicktime', 'video/x-m4v', 'video/mp4', 'video/m4p', 'video/x-flv', 'video/flv', 'audio/mpeg', 'audio/aac', 'audio/mp4', 'audio/x-m4a', 'audio/m4a', 'audio/mp3', 'audio/x-fla', 'audio/fla', 'youtube/flv', 'video/jarisplayer', 'jarisplayer/jarisplayer', 'video/youtube', 'video/rtmp', 'audio/rtmp'];
mediaelement.canThirdPlaySrces = function(mediaElem, srces){
var ret = '';
if(hasSwf || hasYt){
mediaElem = $(mediaElem);
srces = srces || mediaelement.srces(mediaElem);
$.each(srces, function(i, src){
if(src.container && src.src && ((hasSwf && mediaelement.swfMimeTypes.indexOf(src.container) != -1) || (hasYt && src.container == 'video/youtube'))){
ret = src;
return false;
}
});
}
return ret;
};
var nativeCanPlayType = {};
mediaelement.canNativePlaySrces = function(mediaElem, srces){
var ret = '';
if(hasNative){
mediaElem = $(mediaElem);
var nodeName = (mediaElem[0].nodeName || '').toLowerCase();
var nativeCanPlay = (nativeCanPlayType[nodeName] || {prop: {_supvalue: false}}).prop._supvalue || mediaElem[0].canPlayType;
if(!nativeCanPlay){return ret;}
srces = srces || mediaelement.srces(mediaElem);
$.each(srces, function(i, src){
if(src.type && nativeCanPlay.call(mediaElem[0], src.type) ){
ret = src;
return false;
}
});
}
return ret;
};
var emptyType = (/^\s*application\/octet\-stream\s*$/i);
var getRemoveEmptyType = function(){
var ret = emptyType.test($.attr(this, 'type') || '');
if(ret){
$(this).removeAttr('type');
}
return ret;
};
mediaelement.setError = function(elem, message){
if($('source', elem).filter(getRemoveEmptyType).length){
webshims.error('"application/octet-stream" is a useless mimetype for audio/video. Please change this attribute.');
try {
$(elem).mediaLoad();
} catch(er){}
} else {
if(!message){
message = "can't play sources";
}
$(elem).pause().data('mediaerror', message);
webshims.error('mediaelementError: '+ message +'. Run the following line in your console to get more info: webshim.mediaelement.loadDebugger();');
setTimeout(function(){
if($(elem).data('mediaerror')){
$(elem).addClass('media-error').trigger('mediaerror');
}
}, 1);
}
};
var handleThird = (function(){
var requested;
var readyType = hasSwf ? swfType : 'mediaelement-yt';
return function( mediaElem, ret, data ){
//readd to ready
webshims.ready(readyType, function(){
if(mediaelement.createSWF && $(mediaElem).parent()[0]){
mediaelement.createSWF( mediaElem, ret, data );
} else if(!requested) {
requested = true;
loadThird();
handleThird( mediaElem, ret, data );
}
});
if(!requested && hasYt && !mediaelement.createSWF){
loadYt();
}
};
})();
var activate = {
native: function(elem, src, data){
if(data && data.isActive == 'third') {
mediaelement.setActive(elem, 'html5', data);
}
},
third: handleThird
};
var stepSources = function(elem, data, srces){
var i, src;
var testOrder = [{test: 'canNativePlaySrces', activate: 'native'}, {test: 'canThirdPlaySrces', activate: 'third'}];
if(options.preferFlash || (data && data.isActive == 'third') ){
testOrder.reverse();
}
for(i = 0; i < 2; i++){
src = mediaelement[testOrder[i].test](elem, srces);
if(src){
activate[testOrder[i].activate](elem, src, data);
break;
}
}
if(!src){
mediaelement.setError(elem, false);
if(data && data.isActive == 'third') {
mediaelement.setActive(elem, 'html5', data);
}
}
};
var stopParent = /^(?:embed|object|datalist|picture)$/i;
var selectSource = function(elem, data){
var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
var _srces = mediaelement.srces(elem);
var parent = elem.parentNode;
clearTimeout(baseData.loadTimer);
$(elem).removeClass('media-error');
$.data(elem, 'mediaerror', false);
if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
data = data || webshims.data(elem, 'mediaelement');
if(mediaelement.sortMedia){
_srces.sort(mediaelement.sortMedia);
}
stepSources(elem, data, _srces);
};
mediaelement.selectSource = selectSource;
$(document).on('ended', function(e){
var data = webshims.data(e.target, 'mediaelement');
if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;}
setTimeout(function(){
if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;}
$(e.target).prop('currentTime', 0).play();
});
});
var handleMedia = false;
var initMediaElements = function(){
var testFixMedia = function(){
if(webshims.implement(this, 'mediaelement')){
selectSource(this);
if(!support.mediaDefaultMuted && $.attr(this, 'muted') != null){
$.prop(this, 'muted', true);
}
}
};
webshims.ready('dom-support', function(){
handleMedia = true;
if(!supportsLoop){
webshims.defineNodeNamesBooleanProperty(['audio', 'video'], 'loop');
}
['audio', 'video'].forEach(function(nodeName){
var supLoad;
supLoad = webshims.defineNodeNameProperty(nodeName, 'load', {
prop: {
value: function(){
var data = webshims.data(this, 'mediaelement');
selectSource(this, data);
if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
supLoad.prop._supvalue.apply(this, arguments);
}
if(!loadTrackUi.loaded && this.querySelector('track')){
loadTrackUi();
}
$(this).triggerHandler('wsmediareload');
}
}
});
nativeCanPlayType[nodeName] = webshims.defineNodeNameProperty(nodeName, 'canPlayType', {
prop: {
value: function(type){
var ret = '';
if(hasNative && nativeCanPlayType[nodeName].prop._supvalue){
ret = nativeCanPlayType[nodeName].prop._supvalue.call(this, type);
if(ret == 'no'){
ret = '';
}
}
if(!ret && hasSwf){
type = $.trim((type || '').split(';')[0]);
if(mediaelement.swfMimeTypes.indexOf(type) != -1){
ret = 'maybe';
}
}
if(!ret && hasYt && type == 'video/youtube'){
ret = 'maybe';
}
return ret;
}
}
});
});
webshims.onNodeNamesPropertyModify(['audio', 'video'], ['src', 'poster'], {
set: function(){
var elem = this;
var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
clearTimeout(baseData.loadTimer);
baseData.loadTimer = setTimeout(function(){
selectSource(elem);
elem = null;
}, 9);
}
});
webshims.addReady(function(context, insertedElement){
var media = $('video, audio', context)
.add(insertedElement.filter('video, audio'))
.each(testFixMedia)
;
if(!loadTrackUi.loaded && $('track', media).length){
loadTrackUi();
}
media = null;
});
});
if(hasNative && !handleMedia){
webshims.addReady(function(context, insertedElement){
if(!handleMedia){
$('video, audio', context)
.add(insertedElement.filter('video, audio'))
.each(function(){
if(!mediaelement.canNativePlaySrces(this)){
loadThird();
handleMedia = true;
return false;
}
})
;
}
});
}
};
mediaelement.loadDebugger = function(){
webshims.ready('dom-support', function(){
webshims.loader.loadScript('mediaelement-debug');
});
};
if(({noCombo: 1, media: 1})[webshims.cfg.debug]){
$(document).on('mediaerror', function(e){
mediaelement.loadDebugger();
});
}
//set native implementation ready, before swf api is retested
if(hasNative){
webshims.isReady('mediaelement-core', true);
initMediaElements();
webshims.ready('WINDOWLOAD mediaelement', loadThird);
} else {
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
});
})(webshims);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,828 @@
webshims.register('form-native-extend', function($, webshims, window, doc, undefined, options){
"use strict";
var support = webshims.support;
if(!support.formvalidation || webshims.bugs.bustedValidity){return;}
var typeModels = webshims.inputTypes;
var runTest = false;
var validityRules = {};
var updateValidity = (function(){
var timer;
var getValidity = function(){
$(this).prop('validity');
};
var update = function(){
$('input').each(getValidity);
};
return function(){
clearTimeout(timer);
timer = setTimeout(update, 9);
};
})();
webshims.addInputType = function(type, obj){
typeModels[type] = obj;
runTest = true;
//update validity of all implemented input types
if($.isDOMReady && support.formvalidation && !webshims.bugs.bustedValidity){
updateValidity();
}
};
webshims.addValidityRule = function(type, fn){
validityRules[type] = fn;
};
$.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
webshims.addValidityRule(name, function (input, val, cache, validityState){
if(val === ''){return false;}
var ret = validityState[name];
if(!('type' in cache)){
cache.type = (input[0].getAttribute('type') || '').toLowerCase();
}
if(typeModels[cache.type] && typeModels[cache.type][fn]){
ret = typeModels[cache.type][fn](val, input);
}
return ret || false;
});
});
var formsExtModule = webshims.modules['form-number-date-api'];
var overrideValidity = formsExtModule.loaded && !formsExtModule.test();
var validityProps = ['customError', 'badInput','typeMismatch','rangeUnderflow','rangeOverflow','stepMismatch','tooLong', 'tooShort','patternMismatch','valueMissing','valid'];
var validityChanger = ['value'];
var validityElements = [];
var testValidity = function(elem, init){
if(!elem && !runTest){return;}
var type = (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase();
if(typeModels[type]){
$.prop(elem, 'validity');
}
};
var oldSetCustomValidity = {};
['input', 'textarea', 'select'].forEach(function(name){
var desc = webshims.defineNodeNameProperty(name, 'setCustomValidity', {
prop: {
value: function(error){
error = error+'';
var elem = (name == 'input') ? $(this).getNativeElement()[0] : this;
desc.prop._supvalue.call(elem, error);
if(overrideValidity){
webshims.data(elem, 'hasCustomError', !!(error));
testValidity(elem);
}
}
}
});
oldSetCustomValidity[name] = desc.prop._supvalue;
});
if(overrideValidity){
validityChanger.push('min');
validityChanger.push('max');
validityChanger.push('step');
validityElements.push('input');
}
if(overrideValidity){
var stopValidity;
validityElements.forEach(function(nodeName){
var oldDesc = webshims.defineNodeNameProperty(nodeName, 'validity', {
prop: {
get: function(){
if(stopValidity){return;}
var elem = (nodeName == 'input') ? $(this).getNativeElement()[0] : this;
var validity = oldDesc.prop._supget.call(elem);
if(!validity){
return validity;
}
var validityState = {};
validityProps.forEach(function(prop){
validityState[prop] = validity[prop] || false;
});
if( !$.prop(elem, 'willValidate') ){
return validityState;
}
stopValidity = true;
var jElm = $(elem),
cache = {type: (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase(), nodeName: (elem.nodeName || '').toLowerCase()},
val = jElm.val(),
customError = !!(webshims.data(elem, 'hasCustomError')),
setCustomMessage
;
stopValidity = false;
validityState.customError = customError;
if( validityState.valid && validityState.customError ){
validityState.valid = false;
} else if(!validityState.valid) {
var allFalse = true;
$.each(validityState, function(name, prop){
if(prop){
allFalse = false;
return false;
}
});
if(allFalse){
validityState.valid = true;
}
}
$.each(validityRules, function(rule, fn){
validityState[rule] = fn(jElm, val, cache, validityState);
if( validityState[rule] && (validityState.valid || !setCustomMessage) && ((typeModels[cache.type])) ) {
oldSetCustomValidity[nodeName].call(elem, webshims.createValidationMessage(elem, rule));
validityState.valid = false;
setCustomMessage = true;
}
});
if(validityState.valid){
oldSetCustomValidity[nodeName].call(elem, '');
webshims.data(elem, 'hasCustomError', false);
}
return validityState;
},
writeable: false
}
});
});
validityChanger.forEach(function(prop){
webshims.onNodeNamesPropertyModify(validityElements, prop, function(s){
testValidity(this);
});
});
if(doc.addEventListener){
var inputThrottle;
var testPassValidity = function(e){
if(!('form' in e.target)){return;}
clearTimeout(inputThrottle);
testValidity(e.target);
};
doc.addEventListener('change', testPassValidity, true);
doc.addEventListener('input', function(e){
clearTimeout(inputThrottle);
inputThrottle = setTimeout(function(){
testValidity(e.target);
}, 290);
}, true);
}
var validityElementsSel = validityElements.join(',');
webshims.addReady(function(context, elem){
if(runTest){
$(validityElementsSel, context).add(elem.filter(validityElementsSel)).each(function(){
testValidity(this);
});
}
});
} //end: overrideValidity
webshims.defineNodeNameProperty('input', 'type', {
prop: {
get: function(){
var elem = this;
var type = (elem.getAttribute && elem.getAttribute('type') || '').toLowerCase();
return (webshims.inputTypes[type]) ? type : elem.type;
}
}
});
});
;webshims.register('form-number-date-api', function($, webshims, window, document, undefined, options){
"use strict";
if(!webshims.addInputType){
webshims.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')");
}
if(!webshims.getStep){
webshims.getStep = function(elem, type){
var step = $.attr(elem, 'step');
if(step === 'any'){
return step;
}
type = type || getType(elem);
if(!typeModels[type] || !typeModels[type].step){
return step;
}
step = typeProtos.number.asNumber(step);
return ((!isNaN(step) && step > 0) ? step : typeModels[type].step) * (typeModels[type].stepScaleFactor || 1);
};
}
if(!webshims.addMinMaxNumberToCache){
webshims.addMinMaxNumberToCache = function(attr, elem, cache){
if (!(attr+'AsNumber' in cache)) {
cache[attr+'AsNumber'] = typeModels[cache.type].asNumber(elem.attr(attr));
if(isNaN(cache[attr+'AsNumber']) && (attr+'Default' in typeModels[cache.type])){
cache[attr+'AsNumber'] = typeModels[cache.type][attr+'Default'];
}
}
};
}
var nan = parseInt('NaN', 10),
doc = document,
typeModels = webshims.inputTypes,
isNumber = function(string){
return (typeof string == 'number' || (string && string == string * 1));
},
supportsType = function(type){
return ($('<input type="'+type+'" />').prop('type') === type);
},
getType = function(elem){
return (elem.getAttribute('type') || '').toLowerCase();
},
isDateTimePart = function(string){
return (string && !(isNaN(string * 1)));
},
addMinMaxNumberToCache = webshims.addMinMaxNumberToCache,
addleadingZero = function(val, len){
val = ''+val;
len = len - val.length;
for(var i = 0; i < len; i++){
val = '0'+val;
}
return val;
},
EPS = 1e-7,
typeBugs = webshims.bugs.bustedValidity
;
webshims.addValidityRule('stepMismatch', function(input, val, cache, validityState){
if(val === ''){return false;}
if(!('type' in cache)){
cache.type = getType(input[0]);
}
if(cache.type == 'week'){return false;}
var base, attrVal;
var ret = (validityState || {}).stepMismatch || false;
if(typeModels[cache.type] && typeModels[cache.type].step){
if( !('step' in cache) ){
cache.step = webshims.getStep(input[0], cache.type);
}
if(cache.step == 'any'){return false;}
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){return false;}
addMinMaxNumberToCache('min', input, cache);
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = input.prop('defaultValue'))){
base = typeModels[cache.type].asNumber( attrVal );
}
if(isNaN(base)){
base = typeModels[cache.type].stepBase || 0;
}
ret = Math.abs((cache.valueAsNumber - base) % cache.step);
ret = !( ret <= EPS || Math.abs(ret - cache.step) <= EPS );
}
return ret;
});
[{name: 'rangeOverflow', attr: 'max', factor: 1}, {name: 'rangeUnderflow', attr: 'min', factor: -1}].forEach(function(data, i){
webshims.addValidityRule(data.name, function(input, val, cache, validityState) {
var ret = (validityState || {})[data.name] || false;
if(val === ''){return ret;}
if (!('type' in cache)) {
cache.type = getType(input[0]);
}
if (typeModels[cache.type] && typeModels[cache.type].asNumber) {
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){
return false;
}
addMinMaxNumberToCache(data.attr, input, cache);
if(isNaN(cache[data.attr+'AsNumber'])){
return ret;
}
ret = ( cache[data.attr+'AsNumber'] * data.factor < cache.valueAsNumber * data.factor - EPS );
}
return ret;
});
});
webshims.reflectProperties(['input'], ['max', 'min', 'step']);
//IDLs and methods, that aren't part of constrain validation, but strongly tight to it
var valueAsNumberDescriptor = webshims.defineNodeNameProperty('input', 'valueAsNumber', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
var ret = (typeModels[type] && typeModels[type].asNumber) ?
typeModels[type].asNumber($.prop(elem, 'value')) :
(valueAsNumberDescriptor.prop._supget && valueAsNumberDescriptor.prop._supget.apply(elem, arguments));
if(ret == null){
ret = nan;
}
return ret;
},
set: function(val){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].numberToString){
//is NaN a number?
if(isNaN(val)){
$.prop(elem, 'value', '');
return;
}
var set = typeModels[type].numberToString(val);
if(set !== false){
$.prop(elem, 'value', set);
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else if(valueAsNumberDescriptor.prop._supset) {
valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
}
}
}
});
var valueAsDateDescriptor = webshims.defineNodeNameProperty('input', 'valueAsDate', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
return (typeModels[type] && typeModels[type].asDate && !typeModels[type].noAsDate) ?
typeModels[type].asDate($.prop(elem, 'value')) :
valueAsDateDescriptor.prop._supget && valueAsDateDescriptor.prop._supget.call(elem) || null;
},
set: function(value){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].dateToString && !typeModels[type].noAsDate){
if(value === null){
$.prop(elem, 'value', '');
return '';
}
var set = typeModels[type].dateToString(value);
if(set !== false){
$.prop(elem, 'value', set);
return set;
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else {
return valueAsDateDescriptor.prop._supset && valueAsDateDescriptor.prop._supset.apply(elem, arguments) || null;
}
}
}
});
$.each({stepUp: 1, stepDown: -1}, function(name, stepFactor){
var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
prop: {
value: function(factor){
var step, val, valModStep, alignValue, cache, base, attrVal;
var type = getType(this);
if(typeModels[type] && typeModels[type].asNumber){
cache = {type: type};
if(!factor){
factor = 1;
webshims.warn("you should always use a factor for stepUp/stepDown");
}
factor *= stepFactor;
step = webshims.getStep(this, type);
if(step == 'any'){
webshims.info("step is 'any' can't apply stepUp/stepDown");
throw('invalid state error');
}
webshims.addMinMaxNumberToCache('min', $(this), cache);
webshims.addMinMaxNumberToCache('max', $(this), cache);
val = $.prop(this, 'valueAsNumber');
if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
$.prop(this, 'valueAsNumber', cache.minAsNumber);
return;
} else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
$.prop(this, 'valueAsNumber', cache.maxAsNumber);
return;
}
if(isNaN(val)){
val = 0;
}
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
base = typeModels[type].asNumber( attrVal );
}
if(!base){
base = 0;
}
step *= factor;
val = (val + step).toFixed(5) * 1;
valModStep = (val - base) % step;
if ( valModStep && (Math.abs(valModStep) > EPS) ) {
alignValue = val - valModStep;
alignValue += ( valModStep > 0 ) ? step : ( -step );
val = alignValue.toFixed(5) * 1;
}
if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
webshims.info("max/min overflow can't apply stepUp/stepDown");
return;
}
$.prop(this, 'valueAsNumber', val);
} else if(stepDescriptor.prop && stepDescriptor.prop._supvalue){
return stepDescriptor.prop._supvalue.apply(this, arguments);
} else {
webshims.info("no step method for type: "+ type);
throw('invalid state error');
}
}
}
});
});
/*
* ToDO: WEEK
*/
// var getWeek = function(date){
// var time;
// var checkDate = new Date(date.getTime());
//
// checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
//
// time = checkDate.getTime();
// checkDate.setMonth(0);
// checkDate.setDate(1);
// return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
// };
//
// var setWeek = function(year, week){
// var date = new Date(year, 0, 1);
//
// week = (week - 1) * 86400000 * 7;
// date = new Date(date.getTime() + week);
// date.setDate(date.getDate() + 1 - (date.getDay() || 7));
// return date;
// };
var typeProtos = {
number: {
bad: function(val){
return !(isNumber(val));
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 1,
asNumber: function(str){
return (isNumber(str)) ? str * 1 : nan;
},
numberToString: function(num){
return (isNumber(num)) ? num : false;
}
},
range: {
minDefault: 0,
maxDefault: 100
},
color: {
bad: (function(){
var cReg = /^\u0023[a-f0-9]{6}$/;
return function(val){
return (!val || val.length != 7 || !(cReg.test(val)));
};
})()
},
date: {
bad: function(val){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
var i;
var valA = val.split(/\u002D/);
if(valA.length !== 3){return true;}
var ret = false;
if(valA[0].length < 4 || valA[1].length != 2 || valA[1] > 12 || valA[2].length != 2 || valA[2] > 33){
ret = true;
} else {
for(i = 0; i < 3; i++){
if(!isDateTimePart(valA[i])){
ret = true;
break;
}
}
}
return ret || (val !== this.dateToString( this.asDate(val, true) ) );
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 86400000,
asDate: function(val, _noMismatch){
if(!_noMismatch && this.bad(val)){
return null;
}
return new Date(this.asNumber(val, true));
},
asNumber: function(str, _noMismatch){
var ret = nan;
if(_noMismatch || !this.bad(str)){
str = str.split(/\u002D/);
ret = Date.UTC(str[0], str[1] - 1, str[2]);
}
return ret;
},
numberToString: function(num){
return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
},
dateToString: function(date){
return (date && date.getFullYear) ? addleadingZero(date.getUTCFullYear(), 4) +'-'+ addleadingZero(date.getUTCMonth()+1, 2) +'-'+ addleadingZero(date.getUTCDate(), 2) : false;
}
},
/*
* ToDO: WEEK
*/
// week: {
// bad: function(val){
// if(!val || !val.split){return true;}
// var valA = val.split('-W');
// var ret = true;
// if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){
// ret = this.dateToString(setWeek(valA[0], valA[1])) != val;
// }
// return ret;
// },
// step: 1,
// stepScaleFactor: 604800000,
// stepBase: -259200000,
// asDate: function(str, _noMismatch){
// var ret = null;
// if(_noMismatch || !this.bad(str)){
// ret = str.split('-W');
// ret = setWeek(ret[0], ret[1]);
// }
// return ret;
// },
// asNumber: function(str, _noMismatch){
// var ret = nan;
// var date = this.asDate(str, _noMismatch);
// if(date && date.getUTCFullYear){
// ret = date.getTime();
// }
// return ret;
// },
// dateToString: function(date){
// var week, checkDate;
// var ret = false;
// if(date && date.getFullYear){
// week = getWeek(date);
// if(week == 1){
// checkDate = new Date(date.getTime());
// checkDate.setDate(checkDate.getDate() + 7);
// date.setUTCFullYear(checkDate.getUTCFullYear());
// }
// ret = addleadingZero(date.getUTCFullYear(), 4) +'-W'+addleadingZero(week, 2);
// }
// return ret;
// },
// numberToString: function(num){
// return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
// }
// },
time: {
bad: function(val, _getParsed){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
val = val.split(/\u003A/);
if(val.length < 2 || val.length > 3){return true;}
var ret = false,
sFraction;
if(val[2]){
val[2] = val[2].split(/\u002E/);
sFraction = parseInt(val[2][1], 10);
val[2] = val[2][0];
}
$.each(val, function(i, part){
if(!isDateTimePart(part) || part.length !== 2){
ret = true;
return false;
}
});
if(ret){return true;}
if(val[0] > 23 || val[0] < 0 || val[1] > 59 || val[1] < 0){
return true;
}
if(val[2] && (val[2] > 59 || val[2] < 0 )){
return true;
}
if(sFraction && isNaN(sFraction)){
return true;
}
if(sFraction){
if(sFraction < 100){
sFraction *= 100;
} else if(sFraction < 10){
sFraction *= 10;
}
}
return (_getParsed === true) ? [val, sFraction] : false;
},
step: 60,
stepBase: 0,
stepScaleFactor: 1000,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
val = this.bad(val, true);
if(val !== true){
ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
if(val[1]){
ret += val[1];
}
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = addleadingZero(date.getUTCHours(), 2) +':'+ addleadingZero(date.getUTCMinutes(), 2),
tmp = date.getSeconds()
;
if(tmp != "0"){
str += ':'+ addleadingZero(tmp, 2);
}
tmp = date.getUTCMilliseconds();
if(tmp != "0"){
str += '.'+ addleadingZero(tmp, 3);
}
return str;
} else {
return false;
}
}
},
month: {
bad: function(val){
return typeProtos.date.bad(val+'-01');
},
step: 1,
stepScaleFactor: false,
//stepBase: 0, 0 = default
asDate: function(val){
return new Date(typeProtos.date.asNumber(val+'-01'));
},
asNumber: function(val){
//1970-01
var ret = nan;
if(val && !this.bad(val)){
val = val.split(/\u002D/);
val[0] = (val[0] * 1) - 1970;
val[1] = (val[1] * 1) - 1;
ret = (val[0] * 12) + val[1];
}
return ret;
},
numberToString: function(num){
var mod;
var ret = false;
if(isNumber(num)){
mod = (num % 12);
num = ((num - mod) / 12) + 1970;
mod += 1;
if(mod < 1){
num -= 1;
mod += 12;
}
ret = addleadingZero(num, 4)+'-'+addleadingZero(mod, 2);
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = typeProtos.date.dateToString(date);
return (str.split && (str = str.split(/\u002D/))) ? str[0]+'-'+str[1] : false;
} else {
return false;
}
}
}
,'datetime-local': {
bad: function(val, _getParsed){
if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
val = val.split(/\u0054/);
return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
},
noAsDate: true,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
var time = this.bad(val, true);
if(time !== true){
val = val.split(/\u0054/)[0].split(/\u002D/);
ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
if(time[1]){
ret += time[1];
}
}
return ret;
},
dateToString: function(date, _getParsed){
return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
}
}
};
if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
}
//
['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
if(typeBugs || !supportsType(type)){
webshims.addInputType(type, typeProtos[type]);
}
});
if($('<input />').prop('labels') == null){
webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
prop: {
get: function(){
if(this.type == 'hidden'){return null;}
var id = this.id;
var labels = $(this)
.closest('label')
.filter(function(){
var hFor = (this.attributes['for'] || {});
return (!hFor.specified || hFor.value == id);
})
;
if(id) {
labels = labels.add('label[for="'+ id +'"]');
}
return labels.get();
},
writeable: false
}
});
}
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,914 @@
webshims.register('form-number-date-api', function($, webshims, window, document, undefined, options){
"use strict";
if(!webshims.addInputType){
webshims.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')");
}
if(!webshims.getStep){
webshims.getStep = function(elem, type){
var step = $.attr(elem, 'step');
if(step === 'any'){
return step;
}
type = type || getType(elem);
if(!typeModels[type] || !typeModels[type].step){
return step;
}
step = typeProtos.number.asNumber(step);
return ((!isNaN(step) && step > 0) ? step : typeModels[type].step) * (typeModels[type].stepScaleFactor || 1);
};
}
if(!webshims.addMinMaxNumberToCache){
webshims.addMinMaxNumberToCache = function(attr, elem, cache){
if (!(attr+'AsNumber' in cache)) {
cache[attr+'AsNumber'] = typeModels[cache.type].asNumber(elem.attr(attr));
if(isNaN(cache[attr+'AsNumber']) && (attr+'Default' in typeModels[cache.type])){
cache[attr+'AsNumber'] = typeModels[cache.type][attr+'Default'];
}
}
};
}
var nan = parseInt('NaN', 10),
doc = document,
typeModels = webshims.inputTypes,
isNumber = function(string){
return (typeof string == 'number' || (string && string == string * 1));
},
supportsType = function(type){
return ($('<input type="'+type+'" />').prop('type') === type);
},
getType = function(elem){
return (elem.getAttribute('type') || '').toLowerCase();
},
isDateTimePart = function(string){
return (string && !(isNaN(string * 1)));
},
addMinMaxNumberToCache = webshims.addMinMaxNumberToCache,
addleadingZero = function(val, len){
val = ''+val;
len = len - val.length;
for(var i = 0; i < len; i++){
val = '0'+val;
}
return val;
},
EPS = 1e-7,
typeBugs = webshims.bugs.bustedValidity
;
webshims.addValidityRule('stepMismatch', function(input, val, cache, validityState){
if(val === ''){return false;}
if(!('type' in cache)){
cache.type = getType(input[0]);
}
if(cache.type == 'week'){return false;}
var base, attrVal;
var ret = (validityState || {}).stepMismatch || false;
if(typeModels[cache.type] && typeModels[cache.type].step){
if( !('step' in cache) ){
cache.step = webshims.getStep(input[0], cache.type);
}
if(cache.step == 'any'){return false;}
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){return false;}
addMinMaxNumberToCache('min', input, cache);
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = input.prop('defaultValue'))){
base = typeModels[cache.type].asNumber( attrVal );
}
if(isNaN(base)){
base = typeModels[cache.type].stepBase || 0;
}
ret = Math.abs((cache.valueAsNumber - base) % cache.step);
ret = !( ret <= EPS || Math.abs(ret - cache.step) <= EPS );
}
return ret;
});
[{name: 'rangeOverflow', attr: 'max', factor: 1}, {name: 'rangeUnderflow', attr: 'min', factor: -1}].forEach(function(data, i){
webshims.addValidityRule(data.name, function(input, val, cache, validityState) {
var ret = (validityState || {})[data.name] || false;
if(val === ''){return ret;}
if (!('type' in cache)) {
cache.type = getType(input[0]);
}
if (typeModels[cache.type] && typeModels[cache.type].asNumber) {
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){
return false;
}
addMinMaxNumberToCache(data.attr, input, cache);
if(isNaN(cache[data.attr+'AsNumber'])){
return ret;
}
ret = ( cache[data.attr+'AsNumber'] * data.factor < cache.valueAsNumber * data.factor - EPS );
}
return ret;
});
});
webshims.reflectProperties(['input'], ['max', 'min', 'step']);
//IDLs and methods, that aren't part of constrain validation, but strongly tight to it
var valueAsNumberDescriptor = webshims.defineNodeNameProperty('input', 'valueAsNumber', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
var ret = (typeModels[type] && typeModels[type].asNumber) ?
typeModels[type].asNumber($.prop(elem, 'value')) :
(valueAsNumberDescriptor.prop._supget && valueAsNumberDescriptor.prop._supget.apply(elem, arguments));
if(ret == null){
ret = nan;
}
return ret;
},
set: function(val){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].numberToString){
//is NaN a number?
if(isNaN(val)){
$.prop(elem, 'value', '');
return;
}
var set = typeModels[type].numberToString(val);
if(set !== false){
$.prop(elem, 'value', set);
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else if(valueAsNumberDescriptor.prop._supset) {
valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
}
}
}
});
var valueAsDateDescriptor = webshims.defineNodeNameProperty('input', 'valueAsDate', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
return (typeModels[type] && typeModels[type].asDate && !typeModels[type].noAsDate) ?
typeModels[type].asDate($.prop(elem, 'value')) :
valueAsDateDescriptor.prop._supget && valueAsDateDescriptor.prop._supget.call(elem) || null;
},
set: function(value){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].dateToString && !typeModels[type].noAsDate){
if(value === null){
$.prop(elem, 'value', '');
return '';
}
var set = typeModels[type].dateToString(value);
if(set !== false){
$.prop(elem, 'value', set);
return set;
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else {
return valueAsDateDescriptor.prop._supset && valueAsDateDescriptor.prop._supset.apply(elem, arguments) || null;
}
}
}
});
$.each({stepUp: 1, stepDown: -1}, function(name, stepFactor){
var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
prop: {
value: function(factor){
var step, val, valModStep, alignValue, cache, base, attrVal;
var type = getType(this);
if(typeModels[type] && typeModels[type].asNumber){
cache = {type: type};
if(!factor){
factor = 1;
webshims.warn("you should always use a factor for stepUp/stepDown");
}
factor *= stepFactor;
step = webshims.getStep(this, type);
if(step == 'any'){
webshims.info("step is 'any' can't apply stepUp/stepDown");
throw('invalid state error');
}
webshims.addMinMaxNumberToCache('min', $(this), cache);
webshims.addMinMaxNumberToCache('max', $(this), cache);
val = $.prop(this, 'valueAsNumber');
if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
$.prop(this, 'valueAsNumber', cache.minAsNumber);
return;
} else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
$.prop(this, 'valueAsNumber', cache.maxAsNumber);
return;
}
if(isNaN(val)){
val = 0;
}
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
base = typeModels[type].asNumber( attrVal );
}
if(!base){
base = 0;
}
step *= factor;
val = (val + step).toFixed(5) * 1;
valModStep = (val - base) % step;
if ( valModStep && (Math.abs(valModStep) > EPS) ) {
alignValue = val - valModStep;
alignValue += ( valModStep > 0 ) ? step : ( -step );
val = alignValue.toFixed(5) * 1;
}
if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
webshims.info("max/min overflow can't apply stepUp/stepDown");
return;
}
$.prop(this, 'valueAsNumber', val);
} else if(stepDescriptor.prop && stepDescriptor.prop._supvalue){
return stepDescriptor.prop._supvalue.apply(this, arguments);
} else {
webshims.info("no step method for type: "+ type);
throw('invalid state error');
}
}
}
});
});
/*
* ToDO: WEEK
*/
// var getWeek = function(date){
// var time;
// var checkDate = new Date(date.getTime());
//
// checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
//
// time = checkDate.getTime();
// checkDate.setMonth(0);
// checkDate.setDate(1);
// return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
// };
//
// var setWeek = function(year, week){
// var date = new Date(year, 0, 1);
//
// week = (week - 1) * 86400000 * 7;
// date = new Date(date.getTime() + week);
// date.setDate(date.getDate() + 1 - (date.getDay() || 7));
// return date;
// };
var typeProtos = {
number: {
bad: function(val){
return !(isNumber(val));
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 1,
asNumber: function(str){
return (isNumber(str)) ? str * 1 : nan;
},
numberToString: function(num){
return (isNumber(num)) ? num : false;
}
},
range: {
minDefault: 0,
maxDefault: 100
},
color: {
bad: (function(){
var cReg = /^\u0023[a-f0-9]{6}$/;
return function(val){
return (!val || val.length != 7 || !(cReg.test(val)));
};
})()
},
date: {
bad: function(val){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
var i;
var valA = val.split(/\u002D/);
if(valA.length !== 3){return true;}
var ret = false;
if(valA[0].length < 4 || valA[1].length != 2 || valA[1] > 12 || valA[2].length != 2 || valA[2] > 33){
ret = true;
} else {
for(i = 0; i < 3; i++){
if(!isDateTimePart(valA[i])){
ret = true;
break;
}
}
}
return ret || (val !== this.dateToString( this.asDate(val, true) ) );
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 86400000,
asDate: function(val, _noMismatch){
if(!_noMismatch && this.bad(val)){
return null;
}
return new Date(this.asNumber(val, true));
},
asNumber: function(str, _noMismatch){
var ret = nan;
if(_noMismatch || !this.bad(str)){
str = str.split(/\u002D/);
ret = Date.UTC(str[0], str[1] - 1, str[2]);
}
return ret;
},
numberToString: function(num){
return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
},
dateToString: function(date){
return (date && date.getFullYear) ? addleadingZero(date.getUTCFullYear(), 4) +'-'+ addleadingZero(date.getUTCMonth()+1, 2) +'-'+ addleadingZero(date.getUTCDate(), 2) : false;
}
},
/*
* ToDO: WEEK
*/
// week: {
// bad: function(val){
// if(!val || !val.split){return true;}
// var valA = val.split('-W');
// var ret = true;
// if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){
// ret = this.dateToString(setWeek(valA[0], valA[1])) != val;
// }
// return ret;
// },
// step: 1,
// stepScaleFactor: 604800000,
// stepBase: -259200000,
// asDate: function(str, _noMismatch){
// var ret = null;
// if(_noMismatch || !this.bad(str)){
// ret = str.split('-W');
// ret = setWeek(ret[0], ret[1]);
// }
// return ret;
// },
// asNumber: function(str, _noMismatch){
// var ret = nan;
// var date = this.asDate(str, _noMismatch);
// if(date && date.getUTCFullYear){
// ret = date.getTime();
// }
// return ret;
// },
// dateToString: function(date){
// var week, checkDate;
// var ret = false;
// if(date && date.getFullYear){
// week = getWeek(date);
// if(week == 1){
// checkDate = new Date(date.getTime());
// checkDate.setDate(checkDate.getDate() + 7);
// date.setUTCFullYear(checkDate.getUTCFullYear());
// }
// ret = addleadingZero(date.getUTCFullYear(), 4) +'-W'+addleadingZero(week, 2);
// }
// return ret;
// },
// numberToString: function(num){
// return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
// }
// },
time: {
bad: function(val, _getParsed){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
val = val.split(/\u003A/);
if(val.length < 2 || val.length > 3){return true;}
var ret = false,
sFraction;
if(val[2]){
val[2] = val[2].split(/\u002E/);
sFraction = parseInt(val[2][1], 10);
val[2] = val[2][0];
}
$.each(val, function(i, part){
if(!isDateTimePart(part) || part.length !== 2){
ret = true;
return false;
}
});
if(ret){return true;}
if(val[0] > 23 || val[0] < 0 || val[1] > 59 || val[1] < 0){
return true;
}
if(val[2] && (val[2] > 59 || val[2] < 0 )){
return true;
}
if(sFraction && isNaN(sFraction)){
return true;
}
if(sFraction){
if(sFraction < 100){
sFraction *= 100;
} else if(sFraction < 10){
sFraction *= 10;
}
}
return (_getParsed === true) ? [val, sFraction] : false;
},
step: 60,
stepBase: 0,
stepScaleFactor: 1000,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
val = this.bad(val, true);
if(val !== true){
ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
if(val[1]){
ret += val[1];
}
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = addleadingZero(date.getUTCHours(), 2) +':'+ addleadingZero(date.getUTCMinutes(), 2),
tmp = date.getSeconds()
;
if(tmp != "0"){
str += ':'+ addleadingZero(tmp, 2);
}
tmp = date.getUTCMilliseconds();
if(tmp != "0"){
str += '.'+ addleadingZero(tmp, 3);
}
return str;
} else {
return false;
}
}
},
month: {
bad: function(val){
return typeProtos.date.bad(val+'-01');
},
step: 1,
stepScaleFactor: false,
//stepBase: 0, 0 = default
asDate: function(val){
return new Date(typeProtos.date.asNumber(val+'-01'));
},
asNumber: function(val){
//1970-01
var ret = nan;
if(val && !this.bad(val)){
val = val.split(/\u002D/);
val[0] = (val[0] * 1) - 1970;
val[1] = (val[1] * 1) - 1;
ret = (val[0] * 12) + val[1];
}
return ret;
},
numberToString: function(num){
var mod;
var ret = false;
if(isNumber(num)){
mod = (num % 12);
num = ((num - mod) / 12) + 1970;
mod += 1;
if(mod < 1){
num -= 1;
mod += 12;
}
ret = addleadingZero(num, 4)+'-'+addleadingZero(mod, 2);
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = typeProtos.date.dateToString(date);
return (str.split && (str = str.split(/\u002D/))) ? str[0]+'-'+str[1] : false;
} else {
return false;
}
}
}
,'datetime-local': {
bad: function(val, _getParsed){
if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
val = val.split(/\u0054/);
return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
},
noAsDate: true,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
var time = this.bad(val, true);
if(time !== true){
val = val.split(/\u0054/)[0].split(/\u002D/);
ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
if(time[1]){
ret += time[1];
}
}
return ret;
},
dateToString: function(date, _getParsed){
return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
}
}
};
if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
}
//
['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
if(typeBugs || !supportsType(type)){
webshims.addInputType(type, typeProtos[type]);
}
});
if($('<input />').prop('labels') == null){
webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
prop: {
get: function(){
if(this.type == 'hidden'){return null;}
var id = this.id;
var labels = $(this)
.closest('label')
.filter(function(){
var hFor = (this.attributes['for'] || {});
return (!hFor.specified || hFor.value == id);
})
;
if(id) {
labels = labels.add('label[for="'+ id +'"]');
}
return labels.get();
},
writeable: false
}
});
}
});
;webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
"use strict";
var lazyLoad = function(name){
if(!name || typeof name != 'string'){
name = 'DOM';
}
if(!lazyLoad[name+'Loaded']){
lazyLoad[name+'Loaded'] = true;
webshims.ready(name, function(){
webshims.loader.loadList(['form-datalist-lazy']);
});
}
};
var noDatalistSupport = {
submit: 1,
button: 1,
reset: 1,
hidden: 1,
range: 1,
date: 1,
month: 1
};
if(webshims.modules["form-number-date-ui"].loaded){
$.extend(noDatalistSupport, {
number: 1,
time: 1
});
}
/*
* implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
*/
webshims.propTypes.element = function(descs, name){
webshims.createPropDefault(descs, 'attr');
if(descs.prop){return;}
descs.prop = {
get: function(){
var elem = $.attr(this, name);
if(elem){
elem = document.getElementById(elem);
if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
elem = null;
}
}
return elem || null;
},
writeable: false
};
};
/*
* Implements datalist element and list attribute
*/
(function(){
var formsCFG = webshims.cfg.forms;
var listSupport = webshims.support.datalist;
if(listSupport && !formsCFG.customDatalist){return;}
var initializeDatalist = function(){
var updateDatlistAndOptions = function(){
var id;
if(!$.data(this, 'datalistWidgetData') && (id = $.prop(this, 'id'))){
$('input[list="'+ id +'"], input[data-wslist="'+ id +'"]').eq(0).attr('list', id);
} else {
$(this).triggerHandler('updateDatalist');
}
};
var inputListProto = {
//override autocomplete
autocomplete: {
attr: {
get: function(){
var elem = this;
var data = $.data(elem, 'datalistWidget');
if(data){
return data._autocomplete;
}
return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
},
set: function(value){
var elem = this;
var data = $.data(elem, 'datalistWidget');
if(data){
data._autocomplete = value;
if(value == 'off'){
data.hideList();
}
} else {
if('autocomplete' in elem){
elem.autocomplete = value;
} else {
elem.setAttribute('autocomplete', value);
}
}
}
}
}
};
if(listSupport){
//options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
webshims.defineNodeNameProperty('datalist', 'options', {
prop: {
writeable: false,
get: function(){
var options = this.options || [];
if(!options.length){
var elem = this;
var select = $('select', elem);
if(select[0] && select[0].options && select[0].options.length){
options = select[0].options;
}
}
return options;
}
}
});
}
inputListProto.list = {
attr: {
get: function(){
var val = webshims.contentAttr(this, 'list');
if(val != null){
$.data(this, 'datalistListAttr', val);
if(!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]){
this.removeAttribute('list');
}
} else {
val = $.data(this, 'datalistListAttr');
}
return (val == null) ? undefined : val;
},
set: function(value){
var elem = this;
$.data(elem, 'datalistListAttr', value);
if (!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]) {
webshims.objectCreate(shadowListProto, undefined, {
input: elem,
id: value,
datalist: $.prop(elem, 'list')
});
elem.setAttribute('data-wslist', value);
} else {
elem.setAttribute('list', value);
}
$(elem).triggerHandler('listdatalistchange');
}
},
initAttr: true,
reflect: true,
propType: 'element',
propNodeName: 'datalist'
};
} else {
webshims.defineNodeNameProperties('input', {
list: {
attr: {
get: function(){
var val = webshims.contentAttr(this, 'list');
return (val == null) ? undefined : val;
},
set: function(value){
var elem = this;
webshims.contentAttr(elem, 'list', value);
webshims.objectCreate(options.shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
$(elem).triggerHandler('listdatalistchange');
}
},
initAttr: true,
reflect: true,
propType: 'element',
propNodeName: 'datalist'
}
});
}
webshims.defineNodeNameProperties('input', inputListProto);
webshims.addReady(function(context, contextElem){
contextElem
.filter('datalist > select, datalist, datalist > option, datalist > select > option')
.closest('datalist')
.each(updateDatlistAndOptions)
;
});
};
/*
* ShadowList
*/
var shadowListProto = {
_create: function(opts){
if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
var datalist = opts.datalist;
var data = $.data(opts.input, 'datalistWidget');
var that = this;
if(datalist && data && data.datalist !== datalist){
data.datalist = datalist;
data.id = opts.id;
$(data.datalist)
.off('updateDatalist.datalistWidget')
.on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
;
data._resetListCached();
return;
} else if(!datalist){
if(data){
data.destroy();
}
return;
} else if(data && data.datalist === datalist){
return;
}
this.datalist = datalist;
this.id = opts.id;
this.hasViewableData = true;
this._autocomplete = $.attr(opts.input, 'autocomplete');
$.data(opts.input, 'datalistWidget', this);
$.data(datalist, 'datalistWidgetData', this);
lazyLoad('WINDOWLOAD');
if(webshims.isReady('form-datalist-lazy')){
if(window.QUnit){
that._lazyCreate(opts);
} else {
setTimeout(function(){
that._lazyCreate(opts);
}, 9);
}
} else {
$(opts.input).one('focus', lazyLoad);
webshims.ready('form-datalist-lazy', function(){
if(!that._destroyed){
that._lazyCreate(opts);
}
});
}
},
destroy: function(e){
var input;
var autocomplete = $.attr(this.input, 'autocomplete');
$(this.input)
.off('.datalistWidget')
.removeData('datalistWidget')
;
this.shadowList.remove();
$(document).off('.datalist'+this.id);
$(window).off('.datalist'+this.id);
if(this.input.form && this.input.id){
$(this.input.form).off('submit.datalistWidget'+this.input.id);
}
this.input.removeAttribute('aria-haspopup');
if(autocomplete === undefined){
this.input.removeAttribute('autocomplete');
} else {
$(this.input).attr('autocomplete', autocomplete);
}
if(e && e.type == 'beforeunload'){
input = this.input;
setTimeout(function(){
$.attr(input, 'list', $.attr(input, 'list'));
}, 9);
}
this._destroyed = true;
}
};
webshims.loader.addModule('form-datalist-lazy', {
noAutoCallback: true,
options: $.extend(options, {shadowListProto: shadowListProto})
});
if(!options.list){
options.list = {};
}
//init datalist update
initializeDatalist();
})();
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,828 @@
webshims.register('jmebase', function($, webshims, window, doc, undefined){
"use strict";
var props = {};
var fns = {};
var slice = Array.prototype.slice;
var readyLength = 0;
var options = $.extend({selector: '.mediaplayer'}, webshims.cfg.mediaelement.jme);
var baseSelector = options.selector;
webshims.cfg.mediaelement.jme = options;
if(!$.jme){
$.jme = {};
}
$.extend($.jme, {
pluginsClasses: [],
pluginsSel: '',
plugins: {},
props: props,
fns: fns,
data: function(elem, name, value){
var data = $(elem).data('jme') || $.data(elem, 'jme', {});
if(value === undefined){
return (name) ? data[name] : data;
} else {
data[name] = value;
}
},
runPlugin: function(sel){
if(readyLength){
$(document.querySelectorAll(baseSelector)).each(function(){
var controls = this.querySelectorAll(sel);
if(controls.length){
$(this).jmeFn('addControls', controls);
}
});
}
},
registerPlugin: function(name, plugin){
this.plugins[name] = plugin;
if(!plugin.nodeName){
plugin.nodeName = '';
}
if(!plugin.className){
plugin.className = name;
}
this.pluginsClasses.push('.'+plugin.className);
this.pluginsSel = this.pluginsClasses.join(', ');
options[name] = $.extend(plugin.options || {}, options[name]);
if(options[name] && options[name].text){
plugin.text = options[name].text;
} else if(options.i18n && options.i18n[name]){
plugin.text = options.i18n[name];
}
this.runPlugin('.'+plugin.className);
},
configmenuPlugins: {},
addToConfigmenu: function(name, create){
this.configmenuPlugins[name] = create;
},
defineMethod: function(name, fn){
fns[name] = fn;
},
defineProp: function(name, desc){
if(!desc){
desc = {};
}
if(!desc.set){
if(desc.readonly){
desc.set = function(){
throw(name +' is readonly');
};
} else {
desc.set = $.noop;
}
}
if(!desc.get){
desc.get = function(elem){
return $.jme.data(elem, name);
};
}
props[name] = desc;
},
prop: function(elem, name, value){
if(!props[name]){
return $.prop(elem, name, value);
}
if(value === undefined){
return props[name].get( elem );
} else {
var setValue = props[name].set(elem, value);
if(setValue === undefined){
setValue = value;
}
if(setValue != 'noDataSet'){
$.jme.data(elem, name, setValue);
}
}
}
});
$.fn.jmeProp = function(name, value){
return $.access( this, $.jme.prop, name, value, arguments.length > 1 );
};
$.fn.jmeFn = function(fn){
var args = slice.call( arguments, 1 );
var ret;
this.each(function(){
if(!$.jme.data(this).media){
$(this).closest(baseSelector).jmePlayer();
webshims.warn('jmeFn called to early or on wrong element!');
}
ret = (fns[fn] || $.prop(this, fn)).apply(this, args);
if(ret !== undefined){
return false;
}
});
return (ret !== undefined) ? ret : this;
};
var idlStates = {
emptied: 1,
pause: 1
};
var unwaitingEvents = {
canplay: 1, canplaythrough: 1
};
$.jme.initJME = function(context, insertedElement){
readyLength += $(context.querySelectorAll(baseSelector)).add(insertedElement.filter(baseSelector)).jmePlayer().length;
};
$.jme.getDOMList = function(attr){
var list = [];
if(!attr){
attr = [];
}
if(typeof attr == 'string'){
attr = attr.split(' ');
}
$.each(attr, function(i, id){
if(id){
id = document.getElementById(id);
if(id){
list.push(id);
}
}
});
return list;
};
$.jme.getButtonText = function(button, classes){
var isCheckbox;
var lastState;
var txtChangeFn = function(state){
if(lastState === state){return;}
lastState = state;
button
.removeClass(classes[(state) ? 0 : 1])
.addClass(classes[state])
;
if(isCheckbox){
button.prop('checked', !!state);
(button.data('checkboxradio') || {refresh: $.noop}).refresh();
}
};
if (button.is('[type="checkbox"], [type="radio"]')){
button.prop('checked', function(){
return this.defaultChecked;
});
isCheckbox = true;
} else if(button.is('a')){
button.on('click', function(e){
e.preventDefault();
});
}
return txtChangeFn;
};
$.fn.jmePlayer = function(opts){
return this.each(function(){
var mediaUpdateFn, canPlay, removeCanPlay, canplayTimer, lastState, stopEmptiedEvent, forceRender;
var media = $('audio, video', this).eq(0);
var base = $(this);
var jmeData = $.jme.data(this);
var mediaData = $.jme.data(media[0]);
base.addClass(media.prop('nodeName').toLowerCase()+'player');
mediaData.player = base;
mediaData.media = media;
if(!jmeData.media){
forceRender = function(){
base[0].className = base[0].className;
};
removeCanPlay = function(){
media.off('canplay', canPlay);
clearTimeout(canplayTimer);
};
canPlay = function(){
var state = (media.prop('paused')) ? 'idle' : 'playing';
base.attr('data-state', state);
};
mediaUpdateFn = function(e){
var state = e.type;
var readyState;
var paused;
removeCanPlay();
if(unwaitingEvents[state] && lastState != 'waiting'){
return;
}
if(stopEmptiedEvent && state == 'emptied'){
return;
}
if(state == 'ended' || $.prop(this, 'ended')){
state = 'ended';
} else if(state == 'waiting'){
if($.prop(this, 'readyState') > 2){
state = '';
} else {
canplayTimer = setTimeout(function(){
if(media.prop('readyState') > 2){
canPlay();
}
}, 9);
media.on('canPlay', canPlay);
}
} else if(idlStates[state]){
state = 'idle';
} else {
readyState = $.prop(this, 'readyState');
paused = $.prop(this, 'paused');
if(!paused && readyState < 3){
state = 'waiting';
} else if(!paused && readyState > 2){
state = 'playing';
} else {
state = 'idle';
}
}
if(state == 'idle' && base._seekpause){
state = false;
}
if(state){
lastState = state;
base.attr('data-state', state);
setTimeout(forceRender);
}
};
jmeData.media = media;
jmeData.player = base;
media
.on('ended emptied play', (function(){
var timer;
var releaseEmptied = function(){
stopEmptiedEvent = false;
};
var ended = function(){
removeCanPlay();
media.jmeFn('pause');
if(!options.noReload && media.prop('ended') && media.prop('paused') && !media.prop('autoplay') && !media.prop('loop') && !media.hasClass('no-reload')){
stopEmptiedEvent = true;
media.jmeFn('load');
base.attr('data-state', 'ended');
setTimeout(releaseEmptied);
}
};
return function(e){
clearTimeout(timer);
if(e.type == 'ended' && !options.noReload && !media.prop('autoplay') && !media.prop('loop') && !media.hasClass('no-reload')){
timer = setTimeout(ended);
}
};
})())
.on('emptied waiting canplay canplaythrough playing ended pause mediaerror', mediaUpdateFn)
.on('volumechange updateJMEState', function(){
var volume = $.prop(this, 'volume');
base[!volume || $.prop(this, 'muted') ? 'addClass' : 'removeClass']('state-muted');
if(volume < 0.01){
volume = 'no';
} else if(volume < 0.36){
volume = 'low';
} else if(volume < 0.7){
volume = 'medium';
} else {
volume = 'high';
}
base.attr('data-volume', volume);
})
;
if($.jme.pluginsSel){
base.jmeFn('addControls', $(base[0].querySelectorAll($.jme.pluginsSel)));
}
if(mediaUpdateFn){
media.on('updateJMEState', mediaUpdateFn).triggerHandler('updateJMEState');
}
}
});
};
$.jme.defineProp('isPlaying', {
get: function(elem){
return (!$.prop(elem, 'ended') && !$.prop(elem, 'paused') && $.prop(elem, 'readyState') > 1 && !$.data(elem, 'mediaerror'));
},
readonly: true
});
$.jme.defineProp('player', {
readonly: true
});
$.jme.defineProp('media', {
readonly: true
});
$.jme.defineProp('srces', {
get: function(elem){
var srces;
var data = $.jme.data(elem);
var src = data.media.prop('src');
if(src){
return [{src: src}];
}
srces = $.map($('source', data.media).get(), function(source){
var i, len;
var src = {
src: $.prop(source, 'src')
};
var attributes = source.attributes;
for(i = 0, len = attributes.length; i < len; i++){
if(!('specified' in attributes[i]) || attributes[i].specified){
src[attributes[i].nodeName] = attributes[i].nodeValue;
}
}
return src;
});
return srces;
},
set: function(elem, srces){
var data = $.jme.data(elem);
var setSrc = function(i, src){
if(typeof src == 'string'){
src = {src: src};
}
$(document.createElement('source')).attr(src).appendTo(data.media);
};
data.media.removeAttr('src').find('source').remove();
if($.isArray(srces)){
$.each(srces, setSrc);
} else {
setSrc(0, srces);
}
data.media.jmeFn('load');
return 'noDataSet';
}
});
$.jme.defineMethod('togglePlay', function(){
$(this).jmeFn( ( props.isPlaying.get(this) ) ? 'pause' : 'play' );
});
$.jme.defineMethod('addControls', function(controls){
var data = $.jme.data(this) || {};
if(!data.media){return;}
var oldControls = $.jme.data(data.player[0], 'controlElements') || $([]);
controls = $(controls);
if($.jme.pluginsSel){
controls = controls.find($.jme.pluginsSel).add(controls.filter($.jme.pluginsSel));
}
if(controls.length){
$.each($.jme.plugins, function(name, plugin){
var control, options, i, opt;
var pluginControls = controls.filter('.'+plugin.className);
for(i = 0; i < pluginControls.length; i++){
control = $(pluginControls[i]);
options = $.jme.data(pluginControls[i]);
options.player = data.player;
options.media = data.media;
if(!options._rendered){
options._rendered = true;
if(plugin.options){
for(opt in plugin.options){
if(!(opt in options)){
options[opt] = plugin.options[opt];
}
}
}
plugin._create(control, data.media, data.player, options);
}
}
});
$.jme.data(data.player[0], 'controlElements', oldControls.add(controls));
data.player.triggerHandler('controlsadded');
}
});
webshims.ready('DOM mediaelement', function(){
webshims.isReady('jme', true);
webshims.addReady($.jme.initJME);
webshims.isReady('jme-base', true);
if(webshims.cfg.debug !== false && document.getElementsByTagName('video').length && !document.querySelector(baseSelector)){
webshims.warn("found video element but video wasn't wrapped inside a ."+ baseSelector +" element. Will not add control UI");
}
});
});
;webshims.register('mediacontrols', function($, webshims, window){
"use strict";
var pseudoClasses = 'pseudoClasses';
var options = webshims.cfg.mediaelement.jme;
var baseSelector = options.selector;
var jme = $.jme;
var unknownStructure = '<div class="{%class%}"></div>';
var btnStructure = '<button class="{%class%}" type="button" aria-label="{%text%}"></button>';
var slideStructure = '<div class="{%class%} media-range" aria-label="{%text%}"></div>';
var timeStructure = '<div class="{%class%}">00:00</div>';
var noVolumeClass = (function(){
var audio;
var ret = '';
if(window.Audio){
try {
audio = new Audio();
audio.volume = 0.55;
ret = ((Math.round(audio.volume * 100) / 100) == 0.55) ? '' : ' no-volume-api';
} catch(e){}
}
return ret;
})();
var getBarHtml = (function(){
var cache = {};
var regTemplate = /\{\{(.+?)\}\}/igm;
return function(template, invalidCache){
if(!template){
template = options.barTemplate;
}
if(!cache[template] || invalidCache){
cache[template] = template.replace(regTemplate, function(match, matchName){
var plugin = jme.plugins[matchName];
if(plugin){
if(!plugin.structure){
webshims.warn('no structure option provided for plugin: '+ matchName +'. Fallback to standard div');
plugin.structure = unknownStructure;
}
return plugin.structure.replace('{%class%}', matchName).replace('{%text%}', plugin.text || '');
}
return match;
});
}
return cache[template] || '';
};
})();
var ios6 = /iP(hone|od|ad)/i.test(navigator.platform) && parseInt(((navigator.appVersion).match(/OS (\d+)_\d+/) || ['','8'])[1], 10) < 7;
var loadLazy = function(){
if(!loadLazy.loaded){
loadLazy.loaded = true;
webshims.loader.loadList(['mediacontrols-lazy', 'range-ui']);
}
};
var lazyLoadPlugin = function(fn){
if(!fn){
fn = '_create';
}
var rfn = function(c, media){
var obj = this;
var args = arguments;
loadLazy();
webshims.ready('mediacontrols-lazy', function(){
if(rfn != obj[fn] && $.data(media[0])){
return obj[fn].apply(obj, args);
} else {
webshims.error('stop too much recursion');
}
});
};
return rfn;
};
webshims.loader.addModule('mediacontrols-lazy', {
src: 'jme/mediacontrols-lazy'
});
var userActivity = {
_create: lazyLoadPlugin()
};
jme.plugins.useractivity = userActivity;
jme.defineProp('controlbar', {
set: function(elem, value){
value = !!value;
var controls, playerSize;
var data = jme.data(elem);
var controlBar = $('div.jme-mediaoverlay, div.jme-controlbar', data.player);
var structure = '';
if(value && !controlBar[0]){
if(data._controlbar){
data._controlbar.appendTo(data.player);
} else {
if(ios6){
data.media.removeAttr('controls');
data.media.mediaLoad();
}
data.media.prop('controls', false);
structure = getBarHtml();
data._controlbar = $( options.barStructure );
controlBar = data._controlbar.find('div.jme-cb-box').addClass('media-controls');
controls = data._controlbar.filter('.jme-media-overlay');
controls = controls.add( controlBar );
$(structure).appendTo(controlBar);
data._controlbar.appendTo(data.player);
data.player.jmeFn('addControls', controls);
playerSize = (function(){
var lastSize = {};
var sizes = [
{size: 290, name: 'xx-small', names: 's xs xxs'},
{size: 380, name: 'x-small', names: 's xs'},
{size: 478, name: 'small', names: 's'},
{size: 756, name: 'medium', names: 'm'},
{size: 1024, name: 'large', names: 'l'},
{size: Number.MAX_VALUE, name: 'x-large', names: 'l xl'}
];
var len = sizes.length;
return function(){
var size;
var i = 0;
var width = data.player.outerWidth();
var fSize = Math.max(parseInt(data.player.css('fontSize'), 10) || 16, 13);
width = width * (16 / fSize);
for(; i < len; i++){
if(sizes[i].size >= width){
size = sizes[i];
break;
}
}
if(lastSize.name != size.name){
lastSize = size;
data.player.attr('data-playersize', size.name);
data.player.attr('data-playersizes', size.names);
}
};
})();
var $poster = $('<div class="ws-poster" />').insertAfter(data.media);
var posterState = (function(){
var lastPosterState, lastYoutubeState, lastPoster;
var hasFlash = window.swfmini && swfmini.hasFlashPlayerVersion('10.0.3');
var regYt = /youtube\.com\/[watch\?|v\/]+/i;
var isInitial = data.media.prop('paused');
if(isInitial){
data.player.addClass('initial-state');
}
if(!('backgroundSize' in $poster[0].style)){
data.player.addClass('no-backgroundsize');
}
data.media.on('playing waiting seeked seeking', function(){
if(isInitial){
isInitial = false;
data.player.removeClass('initial-state');
}
});
return function(){
var poster = data.media.attr('poster');
var hasPoster = !!poster;
var currentSrc = data.media.prop('currentSrc') || '';
var isYt = regYt.test(currentSrc);
var hasYt = (hasFlash && hasPoster) ? false : isYt;
if(!hasPoster && isYt){
poster = currentSrc.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i) || '';
if(poster){
poster = 'https://img.youtube.com/vi/'+ poster[1] +'/0.jpg';
hasPoster = !!poster;
}
}
if(lastPoster !== poster){
lastPoster = poster;
$poster[0].style.backgroundImage = poster ? 'url('+poster+')' : '';
}
if(lastPosterState !== hasPoster){
lastPosterState = hasPoster;
data.player[hasPoster ? 'removeClass' : 'addClass']('no-poster');
}
if(data.media.prop('paused')){
data.player.addClass('initial-state');
isInitial = true;
}
if(lastYoutubeState !== hasYt){
lastYoutubeState = hasYt;
data.player[hasYt ? 'addClass' : 'removeClass']('has-ytposter');
}
};
})();
userActivity._create(data.player, data.media, data.player);
data.media.on('emptied loadstart', function(){
setTimeout(posterState);
});
playerSize();
posterState();
webshims.ready('dom-support', function(){
data.player.onWSOff('updateshadowdom', playerSize);
controls.add(data._controlbar).add($poster).addClass(webshims.shadowClass);
webshims.addShadowDom();
});
}
} else if(!value) {
controlBar.detach();
}
return value;
}
});
jme.registerPlugin('play-pause', {
structure: btnStructure,
text: 'play / pause',
_create: lazyLoadPlugin()
});
jme.registerPlugin('mute-unmute', {
structure: btnStructure,
text: 'mute / unmute',
_create: lazyLoadPlugin()
});
jme.registerPlugin('jme-media-overlay', {
_create: lazyLoadPlugin()
});
jme.registerPlugin('volume-slider', {
structure: slideStructure,
text: 'volume level',
_create: lazyLoadPlugin()
});
jme.registerPlugin('time-slider', {
structure: slideStructure,
options: {
format: ['mm', 'ss']
},
text: 'time position',
_create: lazyLoadPlugin()
});
jme.defineProp('format', {
set: function(elem, format){
if(!$.isArray(format)){
format = format.split(':');
}
var data = jme.data(elem);
data.format = format;
$(elem).triggerHandler('updatetimeformat');
data.player.triggerHandler('updatetimeformat');
return 'noDataSet';
}
});
jme.registerPlugin('duration-display', {
structure: timeStructure,
options: {
format: "mm:ss"
},
_create: lazyLoadPlugin()
});
jme.defineProp('countdown', {
set: function(elem, value){
var data = jme.data(elem);
data.countdown = !!value;
$(elem).triggerHandler('updatetimeformat');
data.player.triggerHandler('updatetimeformat');
return 'noDataSet';
}
});
jme.registerPlugin('currenttime-display', {
structure: timeStructure,
options: {
format: "mm:ss",
countdown: false
},
_create: lazyLoadPlugin()
});
/**
* Added Poster Plugin
* @author mderting
*/
/*
* the old technique wasn't fully bullet proof
* beside this, jme2 adovactes to use the new improved state-classes to handle visual effect on specific state (see CSS change)
*/
jme.registerPlugin('poster-display', {
structure: '<div />',
options: {
},
_create: lazyLoadPlugin()
});
jme.registerPlugin('fullscreen', {
options: {
fullscreen: true,
autoplayfs: false
},
structure: btnStructure,
text: 'enter fullscreen / exit fullscreen',
_create: lazyLoadPlugin()
});
jme.registerPlugin('mediaconfigmenu', {
structure: btnStructure,
text: 'configuration',
_create: lazyLoadPlugin()
});
jme.registerPlugin('captions', {
structure: btnStructure,
text: 'subtitles',
_create: function(control, media, base){
var trackElems = media.find('track').filter(':not([kind]), [kind="subtitles"], [data-kind="subtitles"], [kind="captions"], [data-kind="captions"]');
control.wsclonedcheckbox = $(control).clone().attr({role: 'checkbox'}).insertBefore(control);
base.attr('data-tracks', trackElems.length > 1 ? 'many' : trackElems.length);
control.attr('aria-haspopup', 'true');
lazyLoadPlugin().apply(this, arguments);
}
});
jme.registerPlugin('chapters', {
structure: btnStructure,
text: 'chapters',
_create: function(control, media, base){
var trackElems = media.find('track').filter('[kind="chapters"], [data-kind="chapters"]');
control.attr('aria-haspopup', 'true');
if(trackElems.length){
webshims._polyfill(['track']);
base.addClass('has-chapter-tracks');
}
lazyLoadPlugin().apply(this, arguments);
}
});
webshims.ready(webshims.cfg.mediaelement.plugins.concat(['mediaelement', 'jme-base']), function(){
if(!options.barTemplate){
options.barTemplate = '<div class="play-pause-container">{{play-pause}}</div><div class="playlist-container"><div class="playlist-box"><div class="playlist-button-container">{{playlist-prev}}</div><div class="playlist-button-container">{{playlist-next}}</div></div></div><div class="currenttime-container">{{currenttime-display}}</div><div class="progress-container">{{time-slider}}</div><div class="duration-container">{{duration-display}}</div><div class="mute-container">{{mute-unmute}}</div><div class="volume-container">{{volume-slider}}</div><div class="chapters-container"><div class="chapters-controls mediamenu-wrapper">{{chapters}}</div></div><div class="subtitle-container mediamenu-wrapper"><div class="subtitle-controls">{{captions}}</div></div><div class="mediaconfig-container"><div class="mediaconfig-controls mediamenu-wrapper">{{mediaconfigmenu}}</div></div><div class="fullscreen-container">{{fullscreen}}</div>';
}
if(!options.barStructure){
options.barStructure = '<div class="jme-media-overlay"></div><div class="jme-controlbar'+ noVolumeClass +'" tabindex="-1"><div class="jme-cb-box"></div></div>';
}
webshims.addReady(function(context, insertedElement){
$(baseSelector, context).add(insertedElement.filter(baseSelector)).jmeProp('controlbar', true);
});
});
webshims.ready('WINDOWLOAD', loadLazy);
});

View File

@ -0,0 +1,148 @@
webshims.register('details', function($, webshims, window, doc, undefined, options){
var isInterActiveSummary = function(summary){
var details = $(summary).parent('details');
if(details[0] && details.children(':first').get(0) === summary){
return details;
}
};
var bindDetailsSummary = function(summary, details){
summary = $(summary);
details = $(details);
var oldSummary = $.data(details[0], 'summaryElement');
$.data(summary[0], 'detailsElement', details);
if(!oldSummary || summary[0] !== oldSummary[0]){
if(oldSummary){
if(oldSummary.hasClass('fallback-summary')){
oldSummary.remove();
} else {
oldSummary
.off('.summaryPolyfill')
.removeData('detailsElement')
.removeAttr('role')
.removeAttr('tabindex')
.removeAttr('aria-expanded')
.removeClass('summary-button')
.find('span.details-open-indicator')
.remove()
;
}
}
$.data(details[0], 'summaryElement', summary);
details.prop('open', details.prop('open'));
}
};
var getSummary = function(details){
var summary = $.data(details, 'summaryElement');
if(!summary){
summary = $(details).children('summary:first-child');
if(!summary[0]){
$(details).prependPolyfill('<summary class="fallback-summary">'+ options.text +'</summary>');
summary = $.data(details, 'summaryElement');
} else {
bindDetailsSummary(summary, details);
}
}
return summary;
};
// var isOriginalPrevented = function(e){
// var src = e.originalEvent;
// if(!src){return e.isDefaultPrevented();}
//
// return src.defaultPrevented || src.returnValue === false ||
// src.getPreventDefault && src.getPreventDefault();
// };
webshims.createElement('summary', function(){
var details = isInterActiveSummary(this);
if(!details || $.data(this, 'detailsElement')){return;}
var timer;
var stopNativeClickTest;
var tabindex = $.attr(this, 'tabIndex') || '0';
bindDetailsSummary(this, details);
$(this)
.on({
'focus.summaryPolyfill': function(){
$(this).addClass('summary-has-focus');
},
'blur.summaryPolyfill': function(){
$(this).removeClass('summary-has-focus');
},
'mouseenter.summaryPolyfill': function(){
$(this).addClass('summary-has-hover');
},
'mouseleave.summaryPolyfill': function(){
$(this).removeClass('summary-has-hover');
},
'click.summaryPolyfill': function(e){
var details = isInterActiveSummary(this);
if(details){
if(!stopNativeClickTest && e.originalEvent){
stopNativeClickTest = true;
e.stopImmediatePropagation();
e.preventDefault();
$(this).trigger('click');
stopNativeClickTest = false;
return false;
} else {
clearTimeout(timer);
timer = setTimeout(function(){
if(!e.isDefaultPrevented()){
details.prop('open', !details.prop('open'));
}
}, 0);
}
}
},
'keydown.summaryPolyfill': function(e){
if( (e.keyCode == 13 || e.keyCode == 32) && !e.isDefaultPrevented()){
stopNativeClickTest = true;
e.preventDefault();
$(this).trigger('click');
stopNativeClickTest = false;
}
}
})
.attr({tabindex: tabindex, role: 'button'})
.prepend('<span class="details-open-indicator" />')
;
webshims.moveToFirstEvent(this, 'click');
});
var initDetails;
webshims.defineNodeNamesBooleanProperty('details', 'open', function(val){
var summary = $($.data(this, 'summaryElement'));
if(!summary){return;}
var action = (val) ? 'removeClass' : 'addClass';
var details = $(this);
if (!initDetails && options.animate){
details.stop().css({width: '', height: ''});
var start = {
width: details.width(),
height: details.height()
};
}
summary.attr('aria-expanded', ''+val);
details[action]('closed-details-summary').children().not(summary[0])[action]('closed-details-child');
if(!initDetails && options.animate){
var end = {
width: details.width(),
height: details.height()
};
details.css(start).animate(end, {
complete: function(){
$(this).css({width: '', height: ''});
}
});
}
});
webshims.createElement('details', function(){
initDetails = true;
var summary = getSummary(this);
$.prop(this, 'open', $.prop(this, 'open'));
initDetails = false;
});
});

File diff suppressed because it is too large Load Diff

1529
public/webshims/shims/es5.js Normal file

File diff suppressed because it is too large Load Diff

1887
public/webshims/shims/es6.js Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,939 @@
// Copyright 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Known Issues:
//
// * Patterns are not implemented.
// * Radial gradient are not implemented. The VML version of these look very
// different from the canvas one.
// * Clipping paths are not implemented.
// * Coordsize. The width and height attribute have higher priority than the
// width and height style values which isn't correct.
// * Painting mode isn't implemented.
// * Canvas width/height should is using content-box by default. IE in
// Quirks mode will draw the canvas using border-box. Either change your
// doctype to HTML5
// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
// or use Box Sizing Behavior from WebFX
// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
// * Non uniform scaling does not correctly scale strokes.
// * Optimize. There is always room for speed improvements.
// Only add this code if we do not already have a canvas implementation
if (!document.createElement('canvas').getContext) {
(function() {
// alias some functions to make (compiled) code shorter
var m = Math;
var mr = m.round;
var ms = m.sin;
var mc = m.cos;
var abs = m.abs;
var sqrt = m.sqrt;
// this is used for sub pixel precision
var Z = 10;
var Z2 = Z / 2;
/**
* This funtion is assigned to the <canvas> elements as element.getContext().
* @this {HTMLElement}
* @return {CanvasRenderingContext2D_}
*/
function getContext() {
return this.context_ ||
(this.context_ = new CanvasRenderingContext2D_(this));
}
var slice = Array.prototype.slice;
/**
* Binds a function to an object. The returned function will always use the
* passed in {@code obj} as {@code this}.
*
* Example:
*
* g = bind(f, obj, a, b)
* g(c, d) // will do f.call(obj, a, b, c, d)
*
* @param {Function} f The function to bind the object to
* @param {Object} obj The object that should act as this when the function
* is called
* @param {*} var_args Rest arguments that will be used as the initial
* arguments when the function is called
* @return {Function} A new function that has bound this
*/
function bind(f, obj, var_args) {
var a = slice.call(arguments, 2);
return function() {
return f.apply(obj, a.concat(slice.call(arguments)));
};
}
var G_vmlCanvasManager_ = {
init: function(opt_doc) {
if (/MSIE/.test(navigator.userAgent) && !window.opera) {
var doc = opt_doc || document;
// Create a dummy element so that IE will allow canvas elements to be
// recognized.
doc.createElement('canvas');
doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
}
},
init_: function(doc) {
// create xmlns
if (!doc.namespaces['g_vml_']) {
doc.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml',
'#default#VML');
}
if (!doc.namespaces['g_o_']) {
doc.namespaces.add('g_o_', 'urn:schemas-microsoft-com:office:office',
'#default#VML');
}
// Setup default CSS. Only add one style sheet per document
if (!doc.styleSheets['ex_canvas_']) {
var ss = doc.createStyleSheet();
ss.owningElement.id = 'ex_canvas_';
ss.cssText = 'canvas{display:inline-block;overflow:hidden;' +
// default size is 300x150 in Gecko and Opera
'text-align:left;width:300px;height:150px}' +
'g_vml_\\:*{behavior:url(#default#VML)}' +
'g_o_\\:*{behavior:url(#default#VML)}';
}
// find all canvas elements
var els = doc.getElementsByTagName('canvas');
for (var i = 0; i < els.length; i++) {
this.initElement(els[i]);
}
},
/**
* Public initializes a canvas element so that it can be used as canvas
* element from now on. This is called automatically before the page is
* loaded but if you are creating elements using createElement you need to
* make sure this is called on the element.
* @param {HTMLElement} el The canvas element to initialize.
* @return {HTMLElement} the element that was created.
*/
initElement: function(el) {
if (!el.getContext) {
el.getContext = getContext;
// Remove fallback content. There is no way to hide text nodes so we
// just remove all childNodes. We could hide all elements and remove
// text nodes but who really cares about the fallback content.
el.innerHTML = '';
// do not use inline function because that will leak memory
el.attachEvent('onpropertychange', onPropertyChange);
el.attachEvent('onresize', onResize);
var attrs = el.attributes;
if (attrs.width && attrs.width.specified) {
// TODO: use runtimeStyle and coordsize
// el.getContext().setWidth_(attrs.width.nodeValue);
el.style.width = attrs.width.nodeValue + 'px';
} else {
el.width = el.clientWidth;
}
if (attrs.height && attrs.height.specified) {
// TODO: use runtimeStyle and coordsize
// el.getContext().setHeight_(attrs.height.nodeValue);
el.style.height = attrs.height.nodeValue + 'px';
} else {
el.height = el.clientHeight;
}
//el.getContext().setCoordsize_()
}
return el;
}
};
function onPropertyChange(e) {
var el = e.srcElement;
switch (e.propertyName) {
case 'width':
el.style.width = el.attributes.width.nodeValue + 'px';
el.getContext().clearRect();
break;
case 'height':
el.style.height = el.attributes.height.nodeValue + 'px';
el.getContext().clearRect();
break;
}
}
function onResize(e) {
var el = e.srcElement;
if (el.firstChild) {
el.firstChild.style.width = el.clientWidth + 'px';
el.firstChild.style.height = el.clientHeight + 'px';
}
}
G_vmlCanvasManager_.init();
// precompute "00" to "FF"
var dec2hex = [];
for (var i = 0; i < 16; i++) {
for (var j = 0; j < 16; j++) {
dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
}
}
function createMatrixIdentity() {
return [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
];
}
function matrixMultiply(m1, m2) {
var result = createMatrixIdentity();
for (var x = 0; x < 3; x++) {
for (var y = 0; y < 3; y++) {
var sum = 0;
for (var z = 0; z < 3; z++) {
sum += m1[x][z] * m2[z][y];
}
result[x][y] = sum;
}
}
return result;
}
function copyState(o1, o2) {
o2.fillStyle = o1.fillStyle;
o2.lineCap = o1.lineCap;
o2.lineJoin = o1.lineJoin;
o2.lineWidth = o1.lineWidth;
o2.miterLimit = o1.miterLimit;
o2.shadowBlur = o1.shadowBlur;
o2.shadowColor = o1.shadowColor;
o2.shadowOffsetX = o1.shadowOffsetX;
o2.shadowOffsetY = o1.shadowOffsetY;
o2.strokeStyle = o1.strokeStyle;
o2.globalAlpha = o1.globalAlpha;
o2.arcScaleX_ = o1.arcScaleX_;
o2.arcScaleY_ = o1.arcScaleY_;
o2.lineScale_ = o1.lineScale_;
}
function processStyle(styleString) {
var str, alpha = 1;
styleString = String(styleString);
if (styleString.substring(0, 3) == 'rgb') {
var start = styleString.indexOf('(', 3);
var end = styleString.indexOf(')', start + 1);
var guts = styleString.substring(start + 1, end).split(',');
str = '#';
for (var i = 0; i < 3; i++) {
str += dec2hex[Number(guts[i])];
}
if (guts.length == 4 && styleString.substr(3, 1) == 'a') {
alpha = guts[3];
}
} else {
str = styleString;
}
return {color: str, alpha: alpha};
}
function processLineCap(lineCap) {
switch (lineCap) {
case 'butt':
return 'flat';
case 'round':
return 'round';
case 'square':
default:
return 'square';
}
}
/**
* This class implements CanvasRenderingContext2D interface as described by
* the WHATWG.
* @param {HTMLElement} surfaceElement The element that the 2D context should
* be associated with
*/
function CanvasRenderingContext2D_(surfaceElement) {
this.m_ = createMatrixIdentity();
this.mStack_ = [];
this.aStack_ = [];
this.currentPath_ = [];
// Canvas context properties
this.strokeStyle = '#000';
this.fillStyle = '#000';
this.lineWidth = 1;
this.lineJoin = 'miter';
this.lineCap = 'butt';
this.miterLimit = Z * 1;
this.globalAlpha = 1;
this.canvas = surfaceElement;
var el = surfaceElement.ownerDocument.createElement('div');
el.style.width = surfaceElement.clientWidth + 'px';
el.style.height = surfaceElement.clientHeight + 'px';
el.style.overflow = 'hidden';
el.style.position = 'absolute';
surfaceElement.appendChild(el);
this.element_ = el;
this.arcScaleX_ = 1;
this.arcScaleY_ = 1;
this.lineScale_ = 1;
}
var contextPrototype = CanvasRenderingContext2D_.prototype;
contextPrototype.clearRect = function() {
this.element_.innerHTML = '';
};
contextPrototype.beginPath = function() {
// TODO: Branch current matrix so that save/restore has no effect
// as per safari docs.
this.currentPath_ = [];
};
contextPrototype.moveTo = function(aX, aY) {
var p = this.getCoords_(aX, aY);
this.currentPath_.push({type: 'moveTo', x: p.x, y: p.y});
this.currentX_ = p.x;
this.currentY_ = p.y;
};
contextPrototype.lineTo = function(aX, aY) {
var p = this.getCoords_(aX, aY);
this.currentPath_.push({type: 'lineTo', x: p.x, y: p.y});
this.currentX_ = p.x;
this.currentY_ = p.y;
};
contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
aCP2x, aCP2y,
aX, aY) {
var p = this.getCoords_(aX, aY);
var cp1 = this.getCoords_(aCP1x, aCP1y);
var cp2 = this.getCoords_(aCP2x, aCP2y);
bezierCurveTo(this, cp1, cp2, p);
};
// Helper function that takes the already fixed cordinates.
function bezierCurveTo(self, cp1, cp2, p) {
self.currentPath_.push({
type: 'bezierCurveTo',
cp1x: cp1.x,
cp1y: cp1.y,
cp2x: cp2.x,
cp2y: cp2.y,
x: p.x,
y: p.y
});
self.currentX_ = p.x;
self.currentY_ = p.y;
}
contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
// the following is lifted almost directly from
// http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes
var cp = this.getCoords_(aCPx, aCPy);
var p = this.getCoords_(aX, aY);
var cp1 = {
x: this.currentX_ + 2.0 / 3.0 * (cp.x - this.currentX_),
y: this.currentY_ + 2.0 / 3.0 * (cp.y - this.currentY_)
};
var cp2 = {
x: cp1.x + (p.x - this.currentX_) / 3.0,
y: cp1.y + (p.y - this.currentY_) / 3.0
};
bezierCurveTo(this, cp1, cp2, p);
};
contextPrototype.arc = function(aX, aY, aRadius,
aStartAngle, aEndAngle, aClockwise) {
aRadius *= Z;
var arcType = aClockwise ? 'at' : 'wa';
var xStart = aX + mc(aStartAngle) * aRadius - Z2;
var yStart = aY + ms(aStartAngle) * aRadius - Z2;
var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
// IE won't render arches drawn counter clockwise if xStart == xEnd.
if (xStart == xEnd && !aClockwise) {
xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something
// that can be represented in binary
}
var p = this.getCoords_(aX, aY);
var pStart = this.getCoords_(xStart, yStart);
var pEnd = this.getCoords_(xEnd, yEnd);
this.currentPath_.push({type: arcType,
x: p.x,
y: p.y,
radius: aRadius,
xStart: pStart.x,
yStart: pStart.y,
xEnd: pEnd.x,
yEnd: pEnd.y});
};
contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
this.moveTo(aX, aY);
this.lineTo(aX + aWidth, aY);
this.lineTo(aX + aWidth, aY + aHeight);
this.lineTo(aX, aY + aHeight);
this.closePath();
};
contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
var oldPath = this.currentPath_;
this.beginPath();
this.moveTo(aX, aY);
this.lineTo(aX + aWidth, aY);
this.lineTo(aX + aWidth, aY + aHeight);
this.lineTo(aX, aY + aHeight);
this.closePath();
this.stroke();
this.currentPath_ = oldPath;
};
contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
var oldPath = this.currentPath_;
this.beginPath();
this.moveTo(aX, aY);
this.lineTo(aX + aWidth, aY);
this.lineTo(aX + aWidth, aY + aHeight);
this.lineTo(aX, aY + aHeight);
this.closePath();
this.fill();
this.currentPath_ = oldPath;
};
contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
var gradient = new CanvasGradient_('gradient');
gradient.x0_ = aX0;
gradient.y0_ = aY0;
gradient.x1_ = aX1;
gradient.y1_ = aY1;
return gradient;
};
contextPrototype.createRadialGradient = function(aX0, aY0, aR0,
aX1, aY1, aR1) {
var gradient = new CanvasGradient_('gradientradial');
gradient.x0_ = aX0;
gradient.y0_ = aY0;
gradient.r0_ = aR0;
gradient.x1_ = aX1;
gradient.y1_ = aY1;
gradient.r1_ = aR1;
return gradient;
};
contextPrototype.drawImage = function(image, var_args) {
var dx, dy, dw, dh, sx, sy, sw, sh;
// to find the original width we overide the width and height
var oldRuntimeWidth = image.runtimeStyle.width;
var oldRuntimeHeight = image.runtimeStyle.height;
image.runtimeStyle.width = 'auto';
image.runtimeStyle.height = 'auto';
// get the original size
var w = image.width;
var h = image.height;
// and remove overides
image.runtimeStyle.width = oldRuntimeWidth;
image.runtimeStyle.height = oldRuntimeHeight;
if (arguments.length == 3) {
dx = arguments[1];
dy = arguments[2];
sx = sy = 0;
sw = dw = w;
sh = dh = h;
} else if (arguments.length == 5) {
dx = arguments[1];
dy = arguments[2];
dw = arguments[3];
dh = arguments[4];
sx = sy = 0;
sw = w;
sh = h;
} else if (arguments.length == 9) {
sx = arguments[1];
sy = arguments[2];
sw = arguments[3];
sh = arguments[4];
dx = arguments[5];
dy = arguments[6];
dw = arguments[7];
dh = arguments[8];
} else {
throw Error('Invalid number of arguments');
}
var d = this.getCoords_(dx, dy);
var w2 = sw / 2;
var h2 = sh / 2;
var vmlStr = [];
var W = 10;
var H = 10;
// For some reason that I've now forgotten, using divs didn't work
vmlStr.push(' <g_vml_:group',
' coordsize="', Z * W, ',', Z * H, '"',
' coordorigin="0,0"' ,
' style="width:', W, 'px;height:', H, 'px;position:absolute;');
// If filters are necessary (rotation exists), create them
// filters are bog-slow, so only create them if abbsolutely necessary
// The following check doesn't account for skews (which don't exist
// in the canvas spec (yet) anyway.
if (this.m_[0][0] != 1 || this.m_[0][1]) {
var filter = [];
// Note the 12/21 reversal
filter.push('M11=', this.m_[0][0], ',',
'M12=', this.m_[1][0], ',',
'M21=', this.m_[0][1], ',',
'M22=', this.m_[1][1], ',',
'Dx=', mr(d.x / Z), ',',
'Dy=', mr(d.y / Z), '');
// Bounding box calculation (need to minimize displayed area so that
// filters don't waste time on unused pixels.
var max = d;
var c2 = this.getCoords_(dx + dw, dy);
var c3 = this.getCoords_(dx, dy + dh);
var c4 = this.getCoords_(dx + dw, dy + dh);
max.x = m.max(max.x, c2.x, c3.x, c4.x);
max.y = m.max(max.y, c2.y, c3.y, c4.y);
vmlStr.push('padding:0 ', mr(max.x / Z), 'px ', mr(max.y / Z),
'px 0;filter:progid:DXImageTransform.Microsoft.Matrix(',
filter.join(''), ", sizingmethod='clip');")
} else {
vmlStr.push('top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px;');
}
vmlStr.push(' ">' ,
'<g_vml_:image src="', image.src, '"',
' style="width:', Z * dw, 'px;',
' height:', Z * dh, 'px;"',
' cropleft="', sx / w, '"',
' croptop="', sy / h, '"',
' cropright="', (w - sx - sw) / w, '"',
' cropbottom="', (h - sy - sh) / h, '"',
' />',
'</g_vml_:group>');
this.element_.insertAdjacentHTML('BeforeEnd',
vmlStr.join(''));
};
contextPrototype.stroke = function(aFill) {
var lineStr = [];
var lineOpen = false;
var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
var color = a.color;
var opacity = a.alpha * this.globalAlpha;
var W = 10;
var H = 10;
lineStr.push('<g_vml_:shape',
' filled="', !!aFill, '"',
' style="position:absolute;width:', W, 'px;height:', H, 'px;"',
' coordorigin="0 0" coordsize="', Z * W, ' ', Z * H, '"',
' stroked="', !aFill, '"',
' path="');
var newSeq = false;
var min = {x: null, y: null};
var max = {x: null, y: null};
for (var i = 0; i < this.currentPath_.length; i++) {
var p = this.currentPath_[i];
var c;
switch (p.type) {
case 'moveTo':
c = p;
lineStr.push(' m ', mr(p.x), ',', mr(p.y));
break;
case 'lineTo':
lineStr.push(' l ', mr(p.x), ',', mr(p.y));
break;
case 'close':
lineStr.push(' x ');
p = null;
break;
case 'bezierCurveTo':
lineStr.push(' c ',
mr(p.cp1x), ',', mr(p.cp1y), ',',
mr(p.cp2x), ',', mr(p.cp2y), ',',
mr(p.x), ',', mr(p.y));
break;
case 'at':
case 'wa':
lineStr.push(' ', p.type, ' ',
mr(p.x - this.arcScaleX_ * p.radius), ',',
mr(p.y - this.arcScaleY_ * p.radius), ' ',
mr(p.x + this.arcScaleX_ * p.radius), ',',
mr(p.y + this.arcScaleY_ * p.radius), ' ',
mr(p.xStart), ',', mr(p.yStart), ' ',
mr(p.xEnd), ',', mr(p.yEnd));
break;
}
// TODO: Following is broken for curves due to
// move to proper paths.
// Figure out dimensions so we can do gradient fills
// properly
if (p) {
if (min.x == null || p.x < min.x) {
min.x = p.x;
}
if (max.x == null || p.x > max.x) {
max.x = p.x;
}
if (min.y == null || p.y < min.y) {
min.y = p.y;
}
if (max.y == null || p.y > max.y) {
max.y = p.y;
}
}
}
lineStr.push(' ">');
if (!aFill) {
var lineWidth = this.lineScale_ * this.lineWidth;
// VML cannot correctly render a line if the width is less than 1px.
// In that case, we dilute the color to make the line look thinner.
if (lineWidth < 1) {
opacity *= lineWidth;
}
lineStr.push(
'<g_vml_:stroke',
' opacity="', opacity, '"',
' joinstyle="', this.lineJoin, '"',
' miterlimit="', this.miterLimit, '"',
' endcap="', processLineCap(this.lineCap), '"',
' weight="', lineWidth, 'px"',
' color="', color, '" />'
);
} else if (typeof this.fillStyle == 'object') {
var fillStyle = this.fillStyle;
var angle = 0;
var focus = {x: 0, y: 0};
// additional offset
var shift = 0;
// scale factor for offset
var expansion = 1;
if (fillStyle.type_ == 'gradient') {
var x0 = fillStyle.x0_ / this.arcScaleX_;
var y0 = fillStyle.y0_ / this.arcScaleY_;
var x1 = fillStyle.x1_ / this.arcScaleX_;
var y1 = fillStyle.y1_ / this.arcScaleY_;
var p0 = this.getCoords_(x0, y0);
var p1 = this.getCoords_(x1, y1);
var dx = p1.x - p0.x;
var dy = p1.y - p0.y;
angle = Math.atan2(dx, dy) * 180 / Math.PI;
// The angle should be a non-negative number.
if (angle < 0) {
angle += 360;
}
// Very small angles produce an unexpected result because they are
// converted to a scientific notation string.
if (angle < 1e-6) {
angle = 0;
}
} else {
var p0 = this.getCoords_(fillStyle.x0_, fillStyle.y0_);
var width = max.x - min.x;
var height = max.y - min.y;
focus = {
x: (p0.x - min.x) / width,
y: (p0.y - min.y) / height
};
width /= this.arcScaleX_ * Z;
height /= this.arcScaleY_ * Z;
var dimension = m.max(width, height);
shift = 2 * fillStyle.r0_ / dimension;
expansion = 2 * fillStyle.r1_ / dimension - shift;
}
// We need to sort the color stops in ascending order by offset,
// otherwise IE won't interpret it correctly.
var stops = fillStyle.colors_;
stops.sort(function(cs1, cs2) {
return cs1.offset - cs2.offset;
});
var length = stops.length;
var color1 = stops[0].color;
var color2 = stops[length - 1].color;
var opacity1 = stops[0].alpha * this.globalAlpha;
var opacity2 = stops[length - 1].alpha * this.globalAlpha;
var colors = [];
for (var i = 0; i < length; i++) {
var stop = stops[i];
colors.push(stop.offset * expansion + shift + ' ' + stop.color);
}
// When colors attribute is used, the meanings of opacity and o:opacity2
// are reversed.
lineStr.push('<g_vml_:fill type="', fillStyle.type_, '"',
' method="none" focus="100%"',
' color="', color1, '"',
' color2="', color2, '"',
' colors="', colors.join(','), '"',
' opacity="', opacity2, '"',
' g_o_:opacity2="', opacity1, '"',
' angle="', angle, '"',
' focusposition="', focus.x, ',', focus.y, '" />');
} else {
lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity,
'" />');
}
lineStr.push('</g_vml_:shape>');
this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
};
contextPrototype.fill = function() {
this.stroke(true);
}
contextPrototype.closePath = function() {
this.currentPath_.push({type: 'close'});
};
/**
* @private
*/
contextPrototype.getCoords_ = function(aX, aY) {
var m = this.m_;
return {
x: Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2,
y: Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2
}
};
contextPrototype.save = function() {
var o = {};
copyState(this, o);
this.aStack_.push(o);
this.mStack_.push(this.m_);
this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
};
contextPrototype.restore = function() {
copyState(this.aStack_.pop(), this);
this.m_ = this.mStack_.pop();
};
function matrixIsFinite(m) {
for (var j = 0; j < 3; j++) {
for (var k = 0; k < 2; k++) {
if (!isFinite(m[j][k]) || isNaN(m[j][k])) {
return false;
}
}
}
return true;
}
function setM(ctx, m, updateLineScale) {
if (!matrixIsFinite(m)) {
return;
}
ctx.m_ = m;
if (updateLineScale) {
// Get the line scale.
// Determinant of this.m_ means how much the area is enlarged by the
// transformation. So its square root can be used as a scale factor
// for width.
var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
ctx.lineScale_ = sqrt(abs(det));
}
}
contextPrototype.translate = function(aX, aY) {
var m1 = [
[1, 0, 0],
[0, 1, 0],
[aX, aY, 1]
];
setM(this, matrixMultiply(m1, this.m_), false);
};
contextPrototype.rotate = function(aRot) {
var c = mc(aRot);
var s = ms(aRot);
var m1 = [
[c, s, 0],
[-s, c, 0],
[0, 0, 1]
];
setM(this, matrixMultiply(m1, this.m_), false);
};
contextPrototype.scale = function(aX, aY) {
this.arcScaleX_ *= aX;
this.arcScaleY_ *= aY;
var m1 = [
[aX, 0, 0],
[0, aY, 0],
[0, 0, 1]
];
setM(this, matrixMultiply(m1, this.m_), true);
};
contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
var m1 = [
[m11, m12, 0],
[m21, m22, 0],
[dx, dy, 1]
];
setM(this, matrixMultiply(m1, this.m_), true);
};
contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) {
var m = [
[m11, m12, 0],
[m21, m22, 0],
[dx, dy, 1]
];
setM(this, m, true);
};
/******** STUBS ********/
contextPrototype.clip = function() {
// TODO: Implement
};
contextPrototype.arcTo = function() {
// TODO: Implement
};
contextPrototype.createPattern = function() {
return new CanvasPattern_;
};
// Gradient / Pattern Stubs
function CanvasGradient_(aType) {
this.type_ = aType;
this.x0_ = 0;
this.y0_ = 0;
this.r0_ = 0;
this.x1_ = 0;
this.y1_ = 0;
this.r1_ = 0;
this.colors_ = [];
}
CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
aColor = processStyle(aColor);
this.colors_.push({offset: aOffset,
color: aColor.color,
alpha: aColor.alpha});
};
function CanvasPattern_() {}
// set up externs
G_vmlCanvasManager = G_vmlCanvasManager_;
CanvasRenderingContext2D = CanvasRenderingContext2D_;
CanvasGradient = CanvasGradient_;
CanvasPattern = CanvasPattern_;
})();
(function(document){
webshims.addReady(function(context, elem){
if(context == document){
if(window.G_vmlCanvasManager && G_vmlCanvasManager.init_ ){
G_vmlCanvasManager.init_(document);
}
}
webshims.$('canvas', context).add(elem.filter('canvas')).each(function(){
var hasContext = this.getContext;
if(!hasContext && window.G_vmlCanvasManager){
G_vmlCanvasManager.initElement(this);
}
});
});
webshims.isReady('canvas', true);
})(document);
} // if

View File

@ -0,0 +1,469 @@
webshim.register('filereader', function($, webshim, window, document, undefined, featureOptions){
"use strict";
var mOxie, moxie, hasXDomain;
var FormData = $.noop;
var sel = 'input[type="file"].ws-filereader';
var loadMoxie = function (){
webshim.loader.loadList(['moxie']);
};
var _createFilePicker = function(){
var $input, picker, $parent, onReset;
var input = this;
if(webshim.implement(input, 'filepicker')){
input = this;
$input = $(this);
$parent = $input.parent();
onReset = function(){
if(!input.value){
$input.prop('value', '');
}
};
$input.attr('tabindex', '-1').on('mousedown.filereaderwaiting click.filereaderwaiting', false);
$parent.addClass('ws-loading');
picker = new mOxie.FileInput({
browse_button: this,
accept: $.prop(this, 'accept'),
multiple: $.prop(this, 'multiple')
});
$input.jProp('form').on('reset', function(){
setTimeout(onReset);
});
picker.onready = function(){
$input.off('.fileraderwaiting');
$parent.removeClass('ws-waiting');
};
picker.onchange = function(e){
webshim.data(input, 'fileList', e.target.files);
$input.trigger('change');
};
picker.onmouseenter = function(){
$input.trigger('mouseover');
$parent.addClass('ws-mouseenter');
};
picker.onmouseleave = function(){
$input.trigger('mouseout');
$parent.removeClass('ws-mouseenter');
};
picker.onmousedown = function(){
$input.trigger('mousedown');
$parent.addClass('ws-active');
};
picker.onmouseup = function(){
$input.trigger('mouseup');
$parent.removeClass('ws-active');
};
webshim.data(input, 'filePicker', picker);
webshim.ready('WINDOWLOAD', function(){
var lastWidth;
$input.onWSOff('updateshadowdom', function(){
var curWitdth = input.offsetWidth;
if(curWitdth && lastWidth != curWitdth){
lastWidth = curWitdth;
picker.refresh();
}
});
});
webshim.addShadowDom();
picker.init();
if(input.disabled){
picker.disable(true);
}
}
};
var getFileNames = function(file){
return file.name;
};
var createFilePicker = function(){
var elem = this;
loadMoxie();
$(elem)
.on('mousedown.filereaderwaiting click.filereaderwaiting', false)
.parent()
.addClass('ws-loading')
;
webshim.ready('moxie', function(){
createFilePicker.call(elem);
});
};
var noxhr = /^(?:script|jsonp)$/i;
var notReadyYet = function(){
loadMoxie();
webshim.error('filereader/formdata not ready yet. please wait for moxie to load `webshim.ready("moxie", callbackFn);`` or wait for the first change event on input[type="file"].ws-filereader.')
};
var inputValueDesc = webshim.defineNodeNameProperty('input', 'value', {
prop: {
get: function(){
var fileList = webshim.data(this, 'fileList');
if(fileList && fileList.map){
return fileList.map(getFileNames).join(', ');
}
return inputValueDesc.prop._supget.call(this);
}
}
}
);
var shimMoxiePath = webshim.cfg.basePath+'moxie/';
var crossXMLMessage = 'You nedd a crossdomain.xml to get all "filereader" / "XHR2" / "CORS" features to work. Or host moxie.swf/moxie.xap on your server an configure filereader options: "swfpath"/"xappath"';
var testMoxie = function(options){
return (options.wsType == 'moxie' || (options.data && options.data instanceof mOxie.FormData) || (options.crossDomain && $.support.cors !== false && hasXDomain != 'no' && !noxhr.test(options.dataType || '')));
};
var createMoxieTransport = function (options){
if(testMoxie(options)){
var ajax;
webshim.info('moxie transfer used for $.ajax');
if(hasXDomain == 'no'){
webshim.error(crossXMLMessage);
}
return {
send: function( headers, completeCallback ) {
var proressEvent = function(obj, name){
if(options[name]){
var called = false;
ajax.addEventListener('load', function(e){
if(!called){
options[name]({type: 'progress', lengthComputable: true, total: 1, loaded: 1});
} else if(called.lengthComputable && called.total > called.loaded){
options[name]({type: 'progress', lengthComputable: true, total: called.total, loaded: called.total});
}
});
obj.addEventListener('progress', function(e){
called = e;
options[name](e);
});
}
};
ajax = new moxie.xhr.XMLHttpRequest();
ajax.open(options.type, options.url, options.async, options.username, options.password);
proressEvent(ajax.upload, featureOptions.uploadprogress);
proressEvent(ajax.upload, featureOptions.progress);
ajax.addEventListener('load', function(e){
var responses = {
text: ajax.responseText,
xml: ajax.responseXML
};
completeCallback(ajax.status, ajax.statusText, responses, ajax.getAllResponseHeaders());
});
if(options.xhrFields && options.xhrFields.withCredentials){
ajax.withCredentials = true;
}
if(options.timeout){
ajax.timeout = options.timeout;
}
$.each(headers, function(name, value){
ajax.setRequestHeader(name, value);
});
ajax.send(options.data);
},
abort: function() {
if(ajax){
ajax.abort();
}
}
};
}
};
var transports = {
//based on script: https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest
xdomain: (function(){
var httpRegEx = /^https?:\/\//i;
var getOrPostRegEx = /^get|post$/i;
var sameSchemeRegEx = new RegExp('^'+location.protocol, 'i');
return function(options, userOptions, jqXHR) {
// Only continue if the request is: asynchronous, uses GET or POST method, has HTTP or HTTPS protocol, and has the same scheme as the calling page
if (!options.crossDomain || options.username || (options.xhrFields && options.xhrFields.withCredentials) || !options.async || !getOrPostRegEx.test(options.type) || !httpRegEx.test(options.url) || !sameSchemeRegEx.test(options.url) || (options.data && options.data instanceof mOxie.FormData) || noxhr.test(options.dataType || '')) {
return;
}
var xdr = null;
webshim.info('xdomain transport used.');
return {
send: function(headers, complete) {
var postData = '';
var userType = (userOptions.dataType || '').toLowerCase();
xdr = new XDomainRequest();
if (/^\d+$/.test(userOptions.timeout)) {
xdr.timeout = userOptions.timeout;
}
xdr.ontimeout = function() {
complete(500, 'timeout');
};
xdr.onload = function() {
var allResponseHeaders = 'Content-Length: ' + xdr.responseText.length + '\r\nContent-Type: ' + xdr.contentType;
var status = {
code: xdr.status || 200,
message: xdr.statusText || 'OK'
};
var responses = {
text: xdr.responseText,
xml: xdr.responseXML
};
try {
if (userType === 'html' || /text\/html/i.test(xdr.contentType)) {
responses.html = xdr.responseText;
} else if (userType === 'json' || (userType !== 'text' && /\/json/i.test(xdr.contentType))) {
try {
responses.json = $.parseJSON(xdr.responseText);
} catch(e) {
}
} else if (userType === 'xml' && !xdr.responseXML) {
var doc;
try {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = false;
doc.loadXML(xdr.responseText);
} catch(e) {
}
responses.xml = doc;
}
} catch(parseMessage) {}
complete(status.code, status.message, responses, allResponseHeaders);
};
// set an empty handler for 'onprogress' so requests don't get aborted
xdr.onprogress = function(){};
xdr.onerror = function() {
complete(500, 'error', {
text: xdr.responseText
});
};
if (userOptions.data) {
postData = ($.type(userOptions.data) === 'string') ? userOptions.data : $.param(userOptions.data);
}
xdr.open(options.type, options.url);
xdr.send(postData);
},
abort: function() {
if (xdr) {
xdr.abort();
}
}
};
};
})(),
moxie: function (options, originalOptions, jqXHR){
if(testMoxie(options)){
loadMoxie(options);
var ajax;
var tmpTransport = {
send: function( headers, completeCallback ) {
ajax = true;
webshim.ready('moxie', function(){
if(ajax){
ajax = createMoxieTransport(options, originalOptions, jqXHR);
tmpTransport.send = ajax.send;
tmpTransport.abort = ajax.abort;
ajax.send(headers, completeCallback);
}
});
},
abort: function() {
ajax = false;
}
};
return tmpTransport;
}
}
};
if(!featureOptions.progress){
featureOptions.progress = 'onprogress';
}
if(!featureOptions.uploadprogress){
featureOptions.uploadprogress = 'onuploadprogress';
}
if(!featureOptions.swfpath){
featureOptions.swfpath = shimMoxiePath+'flash/Moxie.min.swf';
}
if(!featureOptions.xappath){
featureOptions.xappath = shimMoxiePath+'silverlight/Moxie.min.xap';
}
if($.support.cors !== false || !window.XDomainRequest){
delete transports.xdomain;
}
$.ajaxTransport("+*", function( options, originalOptions, jqXHR ) {
var ajax, type;
if(options.wsType || transports[transports]){
ajax = transports[transports](options, originalOptions, jqXHR);
}
if(!ajax){
for(type in transports){
ajax = transports[type](options, originalOptions, jqXHR);
if(ajax){break;}
}
}
return ajax;
});
webshim.defineNodeNameProperty('input', 'files', {
prop: {
writeable: false,
get: function(){
if(this.type != 'file'){return null;}
if(!$(this).is('.ws-filereader')){
webshim.info("please add the 'ws-filereader' class to your input[type='file'] to implement files-property");
}
return webshim.data(this, 'fileList') || [];
}
}
}
);
webshim.reflectProperties(['input'], ['accept']);
if($('<input />').prop('multiple') == null){
webshim.defineNodeNamesBooleanProperty(['input'], ['multiple']);
}
webshim.onNodeNamesPropertyModify('input', 'disabled', function(value, boolVal, type){
var picker = webshim.data(this, 'filePicker');
if(picker){
picker.disable(boolVal);
}
});
webshim.onNodeNamesPropertyModify('input', 'value', function(value, boolVal, type){
if(value === '' && this.type == 'file' && $(this).hasClass('ws-filereader')){
webshim.data(this, 'fileList', []);
}
});
window.FileReader = notReadyYet;
window.FormData = notReadyYet;
webshim.ready('moxie', function(){
var wsMimes = 'application/xml,xml';
moxie = window.moxie;
mOxie = window.mOxie;
mOxie.Env.swf_url = featureOptions.swfpath;
mOxie.Env.xap_url = featureOptions.xappath;
window.FileReader = mOxie.FileReader;
window.FormData = function(form){
var appendData, i, len, files, fileI, fileLen, inputName;
var moxieData = new mOxie.FormData();
if(form && $.nodeName(form, 'form')){
appendData = $(form).serializeArray();
for(i = 0; i < appendData.length; i++){
if(Array.isArray(appendData[i].value)){
appendData[i].value.forEach(function(val){
moxieData.append(appendData[i].name, val);
});
} else {
moxieData.append(appendData[i].name, appendData[i].value);
}
}
appendData = form.querySelectorAll('input[type="file"][name]');
for(i = 0, len = appendData.length; i < appendData.length; i++){
inputName = appendData[i].name;
if(inputName && !$(appendData[i]).is(':disabled')){
files = $.prop(appendData[i], 'files') || [];
if(files.length){
if(files.length > 1 || (moxieData.hasBlob && moxieData.hasBlob())){
webshim.error('FormData shim can only handle one file per ajax. Use multiple ajax request. One per file.');
}
for(fileI = 0, fileLen = files.length; fileI < fileLen; fileI++){
moxieData.append(inputName, files[fileI]);
}
}
}
}
}
return moxieData;
};
FormData = window.FormData;
createFilePicker = _createFilePicker;
transports.moxie = createMoxieTransport;
featureOptions.mimeTypes = (featureOptions.mimeTypes) ? wsMimes+','+featureOptions.mimeTypes : wsMimes;
try {
mOxie.Mime.addMimeType(featureOptions.mimeTypes);
} catch(e){
webshim.warn('mimetype to moxie error: '+e);
}
});
webshim.addReady(function(context, contextElem){
$(context.querySelectorAll(sel)).add(contextElem.filter(sel)).each(createFilePicker);
});
webshim.ready('WINDOWLOAD', loadMoxie);
if(webshim.cfg.debug !== false && featureOptions.swfpath.indexOf((location.protocol+'//'+location.hostname)) && featureOptions.swfpath.indexOf(('https://'+location.hostname))){
webshim.ready('WINDOWLOAD', function(){
var printMessage = function(){
if(hasXDomain == 'no'){
webshim.error(crossXMLMessage);
}
};
try {
hasXDomain = sessionStorage.getItem('wsXdomain.xml');
} catch(e){}
printMessage();
if(hasXDomain == null){
$.ajax({
url: 'crossdomain.xml',
type: 'HEAD',
dataType: 'xml',
success: function(){
hasXDomain = 'yes';
},
error: function(){
hasXDomain = 'no';
},
complete: function(){
try {
sessionStorage.setItem('wsXdomain.xml', hasXDomain);
} catch(e){}
printMessage();
}
});
}
});
}
});

View File

@ -0,0 +1,158 @@
//
webshims.register('form-combat', function($,webshims){
"use strict";
var replacementDatas = {
};
var addReplacement = function(pName, dataName, obj){
if($.fn[pName]){
if(typeof dataName == 'object'){
obj = dataName;
dataName = pName;
}
replacementDatas[dataName] = obj;
webshims.info('detected use of '+ pName +' try to add support.');
}
};
addReplacement('select2', {
shadow: 'container',
shadowFocus: 'focusser',
_create: function(elem, shadow, shadowFocus, widgetData){
if(('container' in widgetData) && $.isFunction(widgetData.opened)){
var onValidate = function(e){
if (!webshims.wsPopover.isInElement([elem, shadow, shadowFocus, $(widgetData.container)], e.target)) {
$(elem).trigger('updatevalidation.webshims');
}
};
$(shadow).on('wsallowinstantvalidation', function(e, data){
$(document).off('focusin', onValidate);
if(data.type == 'focusout' && data.target != elem && widgetData.opened()){
$(document).on('focusin', onValidate);
return false;
}
});
}
}
});
addReplacement('chosen', {
shadow: 'container',
shadowFocus: 'search_field'
});
addReplacement('selectpicker', {
shadow: '$newElement',
shadowFocus: '$button',
_create: function(elem, shadow, shadowFocus, widgetData){
if(('$menu' in widgetData)){
var onValidate = function(e){
if (!webshims.wsPopover.isInElement([elem, shadow, shadowFocus, $(widgetData.$menu)], e.target)) {
$(elem).trigger('updatevalidation.webshims');
}
};
$(shadow).on('wsallowinstantvalidation', function(e, data){
$(document).off('focusin', onValidate);
if(data.type == 'focusout' && data.target != elem){
$(document).on('focusin', onValidate);
return false;
}
});
}
}
});
addReplacement('selectBoxIt', {
shadow: 'dropdownContainer',
shadowFocus: 'dropdown'
});
addReplacement('checkboxradio', 'mobileCheckboxradio', {
shadow: 'label',
shadowFocus: 'element'
});
var uiSelect = {
shadow: 'button',
shadowFocus: function(data){
return data.options.nativeMenu ? data.element : data.button;
},
_create: function(elem, shadow, shadowFocus, widgetData){
var menuName;
if(('menu' in widgetData)){
menuName = 'menuName';
} else if(('listbox' in widgetData)){
menuName = 'listbox';
}
if(menuName){
var onValidate = function(e){
if (!webshims.wsPopover.isInElement([elem, shadow, shadowFocus, $(widgetData[menuName]).parent()], e.target)) {
$(elem).trigger('updatevalidation.webshims');
}
};
$(shadow).on('wsallowinstantvalidation', function(e, data){
if(data.type == 'focusout' && data.target != elem && widgetData.isOpen){
setTimeout(function(){
$(document).off('focusin', onValidate).on('focusin', onValidate);
}, 1);
return false;
}
});
}
}
};
addReplacement('selectmenu', 'mobileSelectmenu', uiSelect);
addReplacement('selectmenu', 'uiSelectmenu', uiSelect);
function find(context){
$('select:not(.ui-select-nativeonly), input[type="radio"], input[type="checkbox"]', context).each(find.detectReplacement);
}
find.register = function(elem, data, pluginDescriptor, plugin){
var shadow = typeof pluginDescriptor.shadow == 'string' ? data[pluginDescriptor.shadow] : pluginDescriptor.shadow(data, elem);
var shadowFocus = typeof pluginDescriptor.shadowFocus == 'string' ? data[pluginDescriptor.shadowFocus] : pluginDescriptor.shadowFocus(data, elem);
if(!shadowFocus){
shadowFocus = shadow;
}
if(shadow && (replacementDatas.success || ($(shadowFocus).attr('tabindex') || $(shadowFocus).prop('tabIndex') > -1))){
webshims.addShadowDom(elem, shadow, {shadowFocusElement: shadowFocus});
if(pluginDescriptor._create){
pluginDescriptor._create(elem, shadow, shadowFocus, data);
}
replacementDatas.success = true;
} else {
webshims.error("webshim could not add support for "+plugin);
if(plugin in replacementDatas){
delete replacementDatas[plugin];
}
}
};
find.detectReplacement = function(){
var plugin;
var data = $(this).data();
if(data && !(webshims.data(this) || {}).hasShadow){
for(plugin in replacementDatas){
if(data[plugin]){
find.register(this, data[plugin], replacementDatas[plugin], plugin);
break;
}
}
}
};
webshims.addReady(function(context){
setTimeout(function(){
find(context);
}, 4);
});
});

View File

@ -0,0 +1,316 @@
webshims.register('form-core', function($, webshims, window, document, undefined, options){
"use strict";
webshims.capturingEventPrevented = function(e){
if(!e._isPolyfilled){
var isDefaultPrevented = e.isDefaultPrevented;
var preventDefault = e.preventDefault;
e.preventDefault = function(){
clearTimeout($.data(e.target, e.type + 'DefaultPrevented'));
$.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){
$.removeData(e.target, e.type + 'DefaultPrevented');
}, 30));
return preventDefault.apply(this, arguments);
};
e.isDefaultPrevented = function(){
return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false);
};
e._isPolyfilled = true;
}
};
var modules = webshims.modules;
var support = webshims.support;
var isValid = function(elem){
return ($.prop(elem, 'validity') || {valid: 1}).valid;
};
var lazyLoad = function(){
var toLoad = ['form-validation'];
if(options.lazyCustomMessages){
options.customMessages = true;
toLoad.push('form-message');
}
if(webshims._getAutoEnhance(options.customDatalist)){
options.fD = true;
toLoad.push('form-datalist');
}
if(options.addValidators){
toLoad.push('form-validators');
}
webshims.reTest(toLoad);
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
*/
var extendSels = function(){
var matches, matchesOverride;
var exp = $.expr[":"];
var rElementsGroup = /^(?:form|fieldset)$/i;
var hasInvalid = function(elem){
var ret = false;
$(elem).jProp('elements').each(function(){
if(!rElementsGroup.test(this.nodeName || '')){
ret = exp.invalid(this);
if(ret){
return false;
}
}
});
return ret;
};
$.extend(exp, {
"valid-element": function(elem){
return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) : !!($.prop(elem, 'willValidate') && isValid(elem));
},
"invalid-element": function(elem){
return rElementsGroup.test(elem.nodeName || '') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
},
"required-element": function(elem){
return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
},
"user-error": function(elem){
return ($.prop(elem, 'willValidate') && $(elem).getShadowElement().hasClass((options.iVal.errorClass || 'user-error')));
},
"optional-element": function(elem){
return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
}
});
['valid', 'invalid', 'required', 'optional'].forEach(function(name){
exp[name] = $.expr[":"][name+"-element"];
});
// sizzle/jQuery has a bug with :disabled/:enabled selectors
if(support.fieldsetdisabled && !$('<fieldset disabled=""><input /><input /></fieldset>').find(':disabled').filter(':disabled').is(':disabled')){
matches = $.find.matches;
matchesOverride = {':disabled': 1, ':enabled': 1};
$.find.matches = function(expr, elements){
if(matchesOverride[expr]){
return matches.call(this, '*'+expr, elements);
}
return matches.apply(this, arguments);
};
$.extend(exp, {
"enabled": function( elem ) {
return elem.disabled === false && !$(elem).is('fieldset[disabled] *');
},
"disabled": function( elem ) {
return elem.disabled === true || ('disabled' in elem && $(elem).is('fieldset[disabled] *'));
}
});
}
//bug was partially fixed in 1.10.0 for IE9, but not IE8 (move to es5 as soon as 1.10.2 is used)
if(typeof document.activeElement == 'unknown'){
var pseudoFocus = exp.focus;
exp.focus = function(){
try {
return pseudoFocus.apply(this, arguments);
} catch(e){
webshims.error(e);
}
return false;
};
}
};
var formExtras = {
noAutoCallback: true,
options: options
};
var addModule = webshims.loader.addModule;
var lazyLoadProxy = function(obj, fn, args){
lazyLoad();
webshims.ready('form-validation', function(){
obj[fn].apply(obj, args);
});
};
var transClass = ('transitionDelay' in document.documentElement.style) ? '' : ' no-transition';
var poCFG = webshims.cfg.wspopover;
addModule('form-validation', $.extend({d: ['form-message']}, formExtras));
addModule('form-validators', $.extend({}, formExtras));
if(support.formvalidation && !webshims.bugs.bustedValidity){
//create delegatable events
webshims.capturingEvents(['invalid'], true);
}
if($.expr.filters){
extendSels();
} else {
webshims.ready('sizzle', extendSels);
}
webshims.triggerInlineForm = function(elem, event){
$(elem).trigger(event);
};
if(!poCFG.position && poCFG.position !== false){
poCFG.position = {
at: 'left bottom',
my: 'left top',
collision: 'fit flip'
};
}
webshims.wsPopover = {
id: 0,
_create: function(){
this.options = $.extend(true, {}, poCFG, this.options);
this.id = webshims.wsPopover.id++;
this.eventns = '.wsoverlay' + this.id;
this.timers = {};
this.element = $('<div class="ws-popover'+transClass+'" tabindex="-1"><div class="ws-po-outerbox"><div class="ws-po-arrow"><div class="ws-po-arrowbox" /></div><div class="ws-po-box" /></div></div>');
this.contentElement = $('.ws-po-box', this.element);
this.lastElement = $([]);
this.bindElement();
this.element.data('wspopover', this);
},
options: {},
content: function(html){
this.contentElement.html(html);
},
bindElement: function(){
var that = this;
var stopBlur = function(){
that.stopBlur = false;
};
this.preventBlur = function(e){
that.stopBlur = true;
clearTimeout(that.timers.stopBlur);
that.timers.stopBlur = setTimeout(stopBlur, 9);
};
this.element.on({
'mousedown': this.preventBlur
});
},
show: function(){
lazyLoadProxy(this, 'show', arguments);
}
};
/* some extra validation UI */
webshims.validityAlert = {
showFor: function(){
lazyLoadProxy(this, 'showFor', arguments);
}
};
webshims.getContentValidationMessage = function(elem, validity, key){
var customRule;
if(webshims.errorbox && webshims.errorbox.initIvalContentMessage){
webshims.errorbox.initIvalContentMessage(elem);
}
var message = (webshims.getOptions && webshims.errorbox ? webshims.getOptions(elem, 'errormessage', false, true) : $(elem).data('errormessage')) || elem.getAttribute('x-moz-errormessage') || '';
if(key && message[key]){
message = message[key];
} else if(message) {
validity = validity || $.prop(elem, 'validity') || {valid: 1};
if(validity.valid){
message = '';
}
}
if(typeof message == 'object'){
validity = validity || $.prop(elem, 'validity') || {valid: 1};
if(validity.customError && (customRule = $.data(elem, 'customMismatchedRule')) && message[customRule] && typeof message[customRule] == 'string'){
message = message[customRule];
} else if(!validity.valid){
$.each(validity, function(name, prop){
if(prop && name != 'valid' && message[name]){
message = message[name];
return false;
}
});
if(typeof message == 'object'){
if(validity.typeMismatch && message.badInput){
message = message.badInput;
}
if(validity.badInput && message.typeMismatch){
message = message.typeMismatch;
}
}
}
}
if(typeof message == 'object'){
message = message.defaultMessage;
}
if(webshims.replaceValidationplaceholder){
message = webshims.replaceValidationplaceholder(elem, message);
}
return message || '';
};
$.fn.getErrorMessage = function(key){
var message = '';
var elem = this[0];
if(elem){
message = webshims.getContentValidationMessage(elem, false, key) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
}
return message;
};
$.event.special.valuevalidation = {
setup: function(){
webshims.error('valuevalidation was renamed to validatevalue!');
}
};
$.event.special.validatevalue = {
setup: function(){
var data = $(this).data() || $.data(this, {});
if(!('validatevalue' in data)){
data.validatevalue = true;
}
}
};
$(document).on('focusin.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
});
webshims.ready('WINDOWLOAD', lazyLoad);
if(modules['form-number-date-ui'].loaded && !options.customMessages && (modules['form-number-date-api'].test() || (support.inputtypes.range && support.inputtypes.color))){
webshims.isReady('form-number-date-ui', true);
}
webshims.ready('DOM', function(){
if(document.querySelector('.ws-custom-file')){
webshims.reTest(['form-validation']);
}
});
$(function(){
var fileReaderReady = ('FileReader' in window && 'FormData' in window);
if(!fileReaderReady){
webshims.addReady(function(context){
if(!fileReaderReady && !modules.filereader.loaded && !modules.moxie.loaded){
if(context.querySelector('input.ws-filereader')){
webshims.reTest(['filereader', 'moxie']);
fileReaderReady = true;
}
}
});
}
});
});

View File

@ -0,0 +1,561 @@
webshims.register('form-datalist-lazy', function($, webshims, window, document, undefined, options){
var optionID = 0;
var formsCFG = $.webshims.cfg.forms;
var globStoredOptions = {};
var getStoredOptions = function(name){
if(!name){return [];}
if(globStoredOptions[name]){
return globStoredOptions[name];
}
var data;
try {
data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
} catch(e){}
globStoredOptions[name] = data || [];
return data || [];
};
var storeOptions = function(name, val){
if(!name){return;}
val = val || [];
try {
localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
} catch(e){}
};
var lReg = /</g;
var gReg = />/g;
var splitReg = /\s*,\s*/g;
webshims.getDataListVal = function(element){
var datalist = $.data(element, 'datalistWidget');
return (datalist) ? datalist.getPartialValue() : $.prop(element, 'value');
};
$.extend(options.shadowListProto, {
_lazyCreate: function(opts){
var that = this;
this.hideList = $.proxy(that, 'hideList');
this.index = -1;
this.input = opts.input;
this.arrayOptions = [];
this._updateOptions();
this.popover = webshims.objectCreate(webshims.wsPopover, {}, this.options.popover);
this.shadowList = this.popover.element.addClass('datalist-polyfill');
this.shadowList
.on('mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', 'li', function(e){
if(that._stopMouseOver && e && e.type == 'mouseenter'){return;}
var items = $('li:not(.hidden-item)', that.shadowList);
var select = (e.type == 'mousedown' || e.type == 'click');
if(select && $(opts.input).getNativeElement().triggerHandler('beforeselect', [$(e.currentTarget).find('.option-value').text()]) === false){
return (e.type != 'mousedown');
}
that.markItem(items.index(e.currentTarget), select, items);
if(e.type == 'click'){
that.hideList();
if(formsCFG.customDatalist){
$(opts.input).getNativeElement().trigger('datalistselect');
}
}
return (e.type != 'mousedown');
})
;
opts.input.setAttribute('autocomplete', 'off');
this.lastCompletedValue = "";
$(opts.input)
.attr({
//role: 'combobox',
'aria-haspopup': 'true',
'aria-autocomplete': 'both' //support only list?
})
.on({
'input.datalistWidget': function(){
if(!that.triggeredByDatalist){
that.changedValue = false;
that.showHideOptions();
}
},
'keydown.datalistWidget': function(e){
var keyCode = e.keyCode;
var activeItem;
var items;
var doValue = !!that.options.inlineValue || 'onlyScroll';
if(keyCode == 40 && !that.showList()){
that.markItem(that.index + 1, doValue);
return false;
}
if(!that.popover.isVisible){return;}
if(keyCode == 38){
that.markItem(that.index - 1, doValue);
return false;
}
if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
that.markItem(0, doValue);
return false;
}
if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
items = $('li:not(.hidden-item)', that.shadowList);
that.markItem(items.length - 1, true, items);
return false;
}
if(keyCode == 13 || keyCode == 27){
if (keyCode == 13){
activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
if(that.isCompleted){
$.prop(opts.input, 'selectionStart', $.prop(opts.input, 'value').length);
if(that.lastCompletedValue && !activeItem[0]){
that.lastCompletedValue = "";
that.isCompleted = false;
}
}
if($(opts.input).getNativeElement().triggerHandler('beforeselect', [activeItem.find('.option-value').text()]) === false){
return;
}
that.changeValue( activeItem );
}
that.hideList();
if(formsCFG.customDatalist && activeItem && activeItem[0]){
$(opts.input).getNativeElement().trigger('datalistselect');
}
if(e.keyCode != 13 || (activeItem && activeItem[0])){
return false;
}
}
},
'focus.datalistWidget': function(){
that.lastCompletedValue = "";
if(that.options.focus){
that.showList();
}
},
'mousedown.datalistWidget': function(){
if($(this).is(':focus')){
that.showList();
}
}
})
;
$(this.datalist)
.off('updateDatalist.datalistWidget')
.on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
.on('remove', function(e){
if(!e.originalEvent){
that.destroy();
}
})
;
this._resetListCached();
if(opts.input.form && (opts.input.name || opts.input.id)){
$(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
var val = $.prop(opts.input, 'value');
var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
if(!that.storedOptions){
that.storedOptions = getStoredOptions( name );
}
if(val && that.storedOptions.indexOf(val) == -1){
that.storedOptions.push(val);
storeOptions(name, that.storedOptions );
}
}
});
}
$(window).on('unload.datalist'+this.id +' beforeunload.datalist'+this.id, function(e){
that.destroy(e);
});
},
_resetListCached: function(e){
var that = this;
var forceShow;
this.needsUpdate = true;
this.lastUpdatedValue = false;
this.lastUnfoundValue = '';
if(!this.updateTimer){
if(window.QUnit || (forceShow = ($(that.input).is(':focus') && (that.options.focus || $.prop(that.input, 'value'))) )){
that.updateListOptions(forceShow);
} else {
that.updateTimer = setTimeout(function(){
that.updateListOptions();
that = null;
}, 200);
}
}
},
_updateOptions: function(){
this.options = webshims.getOptions(this.input, 'list', options.list);
if($(this.input).prop('multiple')){
if($(this.input).prop('type') != 'email'){
webshims.warn('multiple only used on email and file type. Use data-list-multiple instead.');
} else {
this.options.multiple = true;
}
}
if(!this.options.inlineValue && !this.options.valueCompletion){
$.attr(this.input, 'aria-autocomplete', 'list');
$.attr(this.input, 'aria-expanded', 'false');
}
if( this.options.getOptionContent && !$.isFunction(this.options.getOptionContent) ){
this.options.getOptionContent = false;
}
},
updateListOptions: function(_forceShow){
this.needsUpdate = false;
clearTimeout(this.updateTimer);
this.updateTimer = false;
var list = [];
var values = [];
var allOptions = [];
var rElem, rItem, rOptions, rI, rLen, item, value;
for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
rElem = rOptions[rI];
if(!rElem.disabled && (value = $(rElem).val())){
rItem = {
value: this.options.noHtmlEscape ? value : value.replace(lReg, '&lt;').replace(gReg, '&gt;'),
label: $.trim($.attr(rElem, 'label')) || '',
className: rElem.className || '',
elem: rElem
};
if(rItem.label){
rItem.className += ' has-option-label';
}
values.push(rItem.value);
allOptions.push(rItem);
}
}
if(!this.storedOptions){
this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
}
this.storedOptions.forEach(function(val, i){
if(values.indexOf(val) == -1){
allOptions.push({value: val, label: '', className: 'stored-suggest', style: ''});
}
});
for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
item = allOptions[rI];
list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem" id="wsoption-'+ (optionID++) +'">'+ this.getOptionContent(item) +'</li>';
}
this.arrayOptions = allOptions;
this.popover.contentElement.html('<div class="datalist-box"><ul role="listbox">'+ list.join("\n") +'</ul></div>');
$(this.input).removeAttr('aria-activedescendant').triggerHandler('datalistcreated', [{instance: this}]);
if(_forceShow || this.popover.isVisible){
if(this.options.valueCompletion && this.lastCompletedValue && !$.prop(this.input, 'value').indexOf(this.lastCompletedValue)){
$.prop(this.input, 'value', this.lastCompletedValue);
$(this.input).triggerHandler('updateInput');
}
this.lastCompletedValue = "";
this.showHideOptions();
} else {
this.lastCompletedValue = "";
this.isCompleted = false;
}
},
getOptionContent: function(item){
var content;
var args = [{instance: this, item: item}];
if( ( content = $(this.input).triggerHandler('getoptioncontent', args) ) && content.indexOf && content.indexOf('option-value') == -1 ){
content += '<span class="option-value" style="display: none;">'+ item.value +'</span>';
}
if(content == null){
content = '<span class="option-value">'+ item.value +'</span>';
if(item.label){
content += ' <span class="option-label">'+ item.label +'</span>';
}
}
return content || '';
},
setCompletedValue: function(value, foundItem, length){
this.isCompleted = false;
if(!this.options.valueCompletion || !foundItem || this.lastCompletedValue.length >= value.length ){
this.lastCompletedValue = value;
return;
}
var newValue;
var input = this.input;
var end = $.prop(input, 'selectionEnd');
this.lastCompletedValue = value;
if(value.length == end){
newValue = value + foundItem.value.substr(length.length);
$(input).triggerHandler('triggerinput');
$.prop(input, 'value', newValue);
$(input).triggerHandler('updateInput');
$(input).callProp('setSelectionRange', [value.length, newValue.length]);
//safari workaround || needs more investigation
setTimeout(function(){
if(newValue == $.prop(input, 'value') && $.prop(input, 'selectionEnd') != newValue.length){
$.prop(input, 'selectionEnd', newValue.length);
}
}, 0);
this.isCompleted = true;
}
},
getPartialValue: function(){
var value = $.prop(this.input, 'value');
if(this.options.valueCompletion && this.lastCompletedValue && !$.prop(this.input, 'value').indexOf(this.lastCompletedValue)){
value = this.lastCompletedValue;
}
if(this.options.multiple){
value = value.split(splitReg);
value = value[value.length - 1] || '';
}
return value;
},
showHideOptions: function(_fromShowList){
var lis, firstFoundValue;
var inputValue = $.prop(this.input, 'value');
var value = inputValue.toLowerCase();
var found = false;
var startSearch = this.options.filter == '^';
var that = this;
//first check prevent infinite loop, second creates simple lazy optimization
if(value === this.lastUpdatedValue){
return;
}
if(this.options.multiple){
value = value.split(splitReg);
value = value[value.length - 1] || '';
}
if(this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0){
this.hideList();
return;
}
this.lastUpdatedValue = value;
lis = $('li', this.shadowList);
if(value && this.options.filter != '!'){
this.arrayOptions.forEach(function(item, i){
var search, searchIndex, foundName;
if(!('lowerValue' in item)){
item.lowerValue = item.value.toLowerCase();
if(item.label && item.label != item.value ){
item.lowerLabel = item.label.toLowerCase();
}
}
if(value != item.lowerValue && item.lowerLabel != value){
searchIndex = item.lowerValue.indexOf(value);
search = startSearch ? !searchIndex : searchIndex !== -1;
if(search){
foundName = 'value';
if(!firstFoundValue && !searchIndex){
firstFoundValue = item;
}
} else if(item.lowerLabel){
searchIndex = item.lowerLabel.indexOf(value);
search = startSearch ? !searchIndex : searchIndex !== -1;
foundName = 'label';
}
}
if(search){
that.addMark($(lis[i]).removeClass('hidden-item'), item, foundName, searchIndex, value.length);
found = true;
} else {
$(lis[i]).addClass('hidden-item');
}
});
} else if(lis.length) {
this.removeMark(lis.removeClass('hidden-item'));
found = true;
}
this.hasViewableData = found;
if(!_fromShowList && found){
if(this.popover.isVisible && this.popover.element.attr('data-vertical') == 'bottom'){
that._stopMouseOver = true;
this.popover.element.triggerHandler('pospopover');
setTimeout(function(){
that._stopMouseOver = false;
}, 9);
}
this.showList();
}
if(!found){
this.lastUnfoundValue = value;
this.hideList();
} else {
$(this.input).removeAttr('aria-activedescendant');
this.setCompletedValue(inputValue, firstFoundValue, value);
this.lastUnfoundValue = false;
}
},
otherType: {
value: 'label',
label: 'value'
},
addMark: function(elem, item, prop, start, length){
if(this.options.highlight){
var text = item[prop].substr(start, length);
text = item[prop].replace(text ,'<mark>'+ text +'</mark>');
$('.option-'+ this.otherType[prop] +' > mark', elem).each(this._replaceMark);
$('.option-'+prop, elem).html(text);
}
},
_replaceMark: function(){
var content = $(this).html();
$(this).replaceWith(content);
},
removeMark: function(lis){
if(this.options.highlight){
$('mark', lis).each(this._replaceMark);
}
},
showList: function(){
if(this.popover.isVisible){return false;}
if(this.needsUpdate){
this.updateListOptions();
}
this.showHideOptions(true);
if(!this.hasViewableData){return false;}
var that = this;
that.shadowList.find('li.active-item').removeClass('active-item');
that.popover.show(this.input);
$(this.input)
.attr({'aria-expanded': 'true'})
;
return true;
},
hideList: function(){
if(!this.popover.isVisible){return false;}
var that = this;
$(this.input)
.attr({'aria-expanded': 'false'})
.removeAttr('aria-activedescendant')
;
this.popover.hide();
that.shadowList.removeClass('datalist-visible list-item-active');
that.index = -1;
if(that.changedValue){
that.triggeredByDatalist = true;
$(that.input).trigger('input').trigger('change');
that.changedValue = false;
that.triggeredByDatalist = false;
}
return true;
},
scrollIntoView: function(elem){
var ul = $('ul', this.shadowList);
var div = $('div.datalist-box', this.shadowList);
var elemPos = elem.position();
var containerHeight;
elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
if(elemPos.top < 0){
div.scrollTop( div.scrollTop() + elemPos.top - 2);
return;
}
elemPos.top += elem.outerHeight();
containerHeight = div.height();
if(elemPos.top > containerHeight){
div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
}
},
changeValue: function(activeItem){
if(!activeItem[0]){return;}
var spinner, tmpValue;
var newValue = $('span.option-value', activeItem).text();
var oldValue = $.prop(this.input, 'value');
if(this.options.multiple){
tmpValue = oldValue.split(splitReg);
tmpValue[tmpValue.length - 1] = newValue;
newValue = tmpValue.join(', ');
}
if(this.options.valueCompletion && this.lastCompletedValue && !oldValue.indexOf(this.lastCompletedValue)){
oldValue = this.lastCompletedValue;
this.lastCompletedValue = "";
}
if(newValue != oldValue){
$(this.input)
.prop('value', newValue)
.triggerHandler('updateInput')
;
this.changedValue = true;
if((spinner = $.data(this.input, 'wsspinner')) && spinner.setInput){
spinner.setInput(newValue);
}
}
},
markItem: function(index, doValue, items){
var activeItem;
var goesUp;
items = items || $('li:not(.hidden-item)', this.shadowList);
if(!items.length){return;}
if(index < 0){
index = items.length - 1;
} else if(index >= items.length){
index = 0;
}
items.removeClass('active-item');
this.shadowList.addClass('list-item-active');
activeItem = items.filter(':eq('+ index +')').addClass('active-item');
if(doValue){
if(doValue != 'onlyScroll'){
this.changeValue(activeItem);
} else {
$(this.input).attr('aria-activedescendant', activeItem.prop('id'));
}
this.scrollIntoView(activeItem);
}
this.index = index;
}
});
});

View File

@ -0,0 +1,297 @@
webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
"use strict";
var lazyLoad = function(name){
if(!name || typeof name != 'string'){
name = 'DOM';
}
if(!lazyLoad[name+'Loaded']){
lazyLoad[name+'Loaded'] = true;
webshims.ready(name, function(){
webshims.loader.loadList(['form-datalist-lazy']);
});
}
};
var noDatalistSupport = {
submit: 1,
button: 1,
reset: 1,
hidden: 1,
range: 1,
date: 1,
month: 1
};
if(webshims.modules["form-number-date-ui"].loaded){
$.extend(noDatalistSupport, {
number: 1,
time: 1
});
}
/*
* implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
*/
webshims.propTypes.element = function(descs, name){
webshims.createPropDefault(descs, 'attr');
if(descs.prop){return;}
descs.prop = {
get: function(){
var elem = $.attr(this, name);
if(elem){
elem = document.getElementById(elem);
if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
elem = null;
}
}
return elem || null;
},
writeable: false
};
};
/*
* Implements datalist element and list attribute
*/
(function(){
var formsCFG = webshims.cfg.forms;
var listSupport = webshims.support.datalist;
if(listSupport && !formsCFG.customDatalist){return;}
var initializeDatalist = function(){
var updateDatlistAndOptions = function(){
var id;
if(!$.data(this, 'datalistWidgetData') && (id = $.prop(this, 'id'))){
$('input[list="'+ id +'"], input[data-wslist="'+ id +'"]').eq(0).attr('list', id);
} else {
$(this).triggerHandler('updateDatalist');
}
};
var inputListProto = {
//override autocomplete
autocomplete: {
attr: {
get: function(){
var elem = this;
var data = $.data(elem, 'datalistWidget');
if(data){
return data._autocomplete;
}
return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
},
set: function(value){
var elem = this;
var data = $.data(elem, 'datalistWidget');
if(data){
data._autocomplete = value;
if(value == 'off'){
data.hideList();
}
} else {
if('autocomplete' in elem){
elem.autocomplete = value;
} else {
elem.setAttribute('autocomplete', value);
}
}
}
}
}
};
if(listSupport){
//options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
webshims.defineNodeNameProperty('datalist', 'options', {
prop: {
writeable: false,
get: function(){
var options = this.options || [];
if(!options.length){
var elem = this;
var select = $('select', elem);
if(select[0] && select[0].options && select[0].options.length){
options = select[0].options;
}
}
return options;
}
}
});
}
inputListProto.list = {
attr: {
get: function(){
var val = webshims.contentAttr(this, 'list');
if(val != null){
$.data(this, 'datalistListAttr', val);
if(!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]){
this.removeAttribute('list');
}
} else {
val = $.data(this, 'datalistListAttr');
}
return (val == null) ? undefined : val;
},
set: function(value){
var elem = this;
$.data(elem, 'datalistListAttr', value);
if (!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]) {
webshims.objectCreate(shadowListProto, undefined, {
input: elem,
id: value,
datalist: $.prop(elem, 'list')
});
elem.setAttribute('data-wslist', value);
} else {
elem.setAttribute('list', value);
}
$(elem).triggerHandler('listdatalistchange');
}
},
initAttr: true,
reflect: true,
propType: 'element',
propNodeName: 'datalist'
};
} else {
webshims.defineNodeNameProperties('input', {
list: {
attr: {
get: function(){
var val = webshims.contentAttr(this, 'list');
return (val == null) ? undefined : val;
},
set: function(value){
var elem = this;
webshims.contentAttr(elem, 'list', value);
webshims.objectCreate(options.shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
$(elem).triggerHandler('listdatalistchange');
}
},
initAttr: true,
reflect: true,
propType: 'element',
propNodeName: 'datalist'
}
});
}
webshims.defineNodeNameProperties('input', inputListProto);
webshims.addReady(function(context, contextElem){
contextElem
.filter('datalist > select, datalist, datalist > option, datalist > select > option')
.closest('datalist')
.each(updateDatlistAndOptions)
;
});
};
/*
* ShadowList
*/
var shadowListProto = {
_create: function(opts){
if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
var datalist = opts.datalist;
var data = $.data(opts.input, 'datalistWidget');
var that = this;
if(datalist && data && data.datalist !== datalist){
data.datalist = datalist;
data.id = opts.id;
$(data.datalist)
.off('updateDatalist.datalistWidget')
.on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
;
data._resetListCached();
return;
} else if(!datalist){
if(data){
data.destroy();
}
return;
} else if(data && data.datalist === datalist){
return;
}
this.datalist = datalist;
this.id = opts.id;
this.hasViewableData = true;
this._autocomplete = $.attr(opts.input, 'autocomplete');
$.data(opts.input, 'datalistWidget', this);
$.data(datalist, 'datalistWidgetData', this);
lazyLoad('WINDOWLOAD');
if(webshims.isReady('form-datalist-lazy')){
if(window.QUnit){
that._lazyCreate(opts);
} else {
setTimeout(function(){
that._lazyCreate(opts);
}, 9);
}
} else {
$(opts.input).one('focus', lazyLoad);
webshims.ready('form-datalist-lazy', function(){
if(!that._destroyed){
that._lazyCreate(opts);
}
});
}
},
destroy: function(e){
var input;
var autocomplete = $.attr(this.input, 'autocomplete');
$(this.input)
.off('.datalistWidget')
.removeData('datalistWidget')
;
this.shadowList.remove();
$(document).off('.datalist'+this.id);
$(window).off('.datalist'+this.id);
if(this.input.form && this.input.id){
$(this.input.form).off('submit.datalistWidget'+this.input.id);
}
this.input.removeAttribute('aria-haspopup');
if(autocomplete === undefined){
this.input.removeAttribute('autocomplete');
} else {
$(this.input).attr('autocomplete', autocomplete);
}
if(e && e.type == 'beforeunload'){
input = this.input;
setTimeout(function(){
$.attr(input, 'list', $.attr(input, 'list'));
}, 9);
}
this._destroyed = true;
}
};
webshims.loader.addModule('form-datalist-lazy', {
noAutoCallback: true,
options: $.extend(options, {shadowListProto: shadowListProto})
});
if(!options.list){
options.list = {};
}
//init datalist update
initializeDatalist();
})();
});

View File

@ -0,0 +1,137 @@
webshims.register('form-fixrangechange', function($, webshims){
"use strict";
var rangeChange = {
trigger: function(e){
if(rangeChange.blockElement){
rangeChange.blockElement = false;
setTimeout(function(){
if(rangeChange.requestedChange && rangeChange.value != rangeChange.requestedChange.value){
$(rangeChange.requestedChange).trigger('change');
}
rangeChange.value = false;
}, 9);
}
},
lastValue: false,
updateInputValue: function(e){
rangeChange.lastValue = e.target.value;
},
triggerInput: function(e){
if(rangeChange.lastValue !== false && rangeChange.lastValue != e.target.value){
$(e.target).trigger('input');
}
},
inputTeardown: function(e){
$(e.target)
.off('input', rangeChange.updateInputValue)
.off('blur', rangeChange.inputTeardown)
;
rangeChange.lastValue = false;
},
inputSetup: function(e){
if(e.target.type == 'range'){
rangeChange.inputTeardown(e);
rangeChange.lastValue = e.target.value;
$(e.target)
.on('input', rangeChange.updateInputValue)
.on('blur', rangeChange.inputTeardown)
;
}
}
};
$.each([{name: 'key', evt: 'keyup'}, {name: 'mouse', evt: 'mouseup'}, {name: 'touch', evt: 'touchend'}], function(i, obj){
var setup = obj.name + 'Setup';
var commit = obj.name + 'Commit';
rangeChange[obj.name+'Block'] = function(e){
if(!rangeChange.blockElement && e.target.type == 'range'){
rangeChange.blockElement = e.target;
rangeChange.value = e.target.value;
$(rangeChange.blockElement)
.off('blur', rangeChange.trigger)
.on('blur', rangeChange.trigger)
;
$(document.body)
.off(obj.evt, rangeChange[commit])
.on(obj.evt, rangeChange[commit])
;
}
};
rangeChange[commit] = function(e){
$(document.body).off(obj.evt, rangeChange[commit]);
rangeChange.trigger();
};
});
$(document.body || 'html').on({
mousedown: rangeChange.mouseBlock,
'keydown kepress': function(e){
if(e.keyCode < 45 && e.keyCode > 30){
rangeChange.keyBlock(e);
}
},
'touchstart': rangeChange.touchBlock,
focusin: rangeChange.inputSetup
});
$.extend(true, $.event.special, {
change: {
handle: function(e){
if(!e.isTrigger && rangeChange.blockElement == e.target){
rangeChange.requestedChange = e.target;
rangeChange.triggerInput(e);
return false;
} else if(rangeChange.requestedChange == e.target){
rangeChange.requestedChange = false;
}
e.handleObj.handler.apply(this, arguments);
}
},
input: {
handle: (function(){
var lastValue, lastElement;
var remove = function(){
if(lastElement){
$(lastElement).off('change', remove);
}
lastValue = false;
lastElement = false;
};
var setup = function(e){
remove(e);
lastElement = e.target;
lastValue = e.target.value;
$(e.target).on('change', remove);
};
return function(e){
var value;
if(!e.isTrigger && e.target.type == 'range'){
if(lastElement != e.target){
setup(e);
} else if(lastElement == e.target){
if(lastValue == (value = e.target.value)){
return false;
}
lastValue = e.target.value;
}
}
e.handleObj.handler.apply(this, arguments);
};
})()
}
});
});

View File

@ -0,0 +1,52 @@
webshim.register('form-inputmode', function($, webshims, window, document, undefined, options){
"use strict";
var ua = navigator.userAgent;
var removeListener = function(elem){
elem.removeEventListener('blur', switchBack, true);
};
var needsPattern = (/iphone|ipod/i).test(ua);
var regPattern = /^[\\d\*|\[0\-9\]]*[\+|\{\d*\,\d*\}|*]*$/;
var stopPatterns = needsPattern || (/ipad|ios/i).test(ua) ?
{
'[0-9]*': 1,
'\\d*': 1
} :
false
;
var switchBack = function(e){
removeListener(e.target);
e.target.type = 'text';
};
var removeDocListener = function(){
document.removeEventListener('focus', addFix, true);
document.removeEventListener('touchstart', addFix, true);
};
var allowSwitchByPattern = function(elem){
var pattern;
var switchAllowed = true;
if(stopPatterns){
pattern = elem.getAttribute('pattern') || '';
if(stopPatterns[pattern] || (needsPattern && (!pattern || !regPattern.test(pattern)))){
switchAllowed = false;
}
}
return switchAllowed;
};
var addFix = function(e){
if(e.target.type == 'text' && e.target.getAttribute('inputmode') == 'numeric' && allowSwitchByPattern(e.target)){
try{
removeListener(e.target);
e.target.addEventListener('blur', switchBack, true);
e.target.type = 'tel';
} catch (er){
removeDocListener();
}
}
};
document.addEventListener('focus', addFix, true);
document.addEventListener('touchstart', addFix, true);
});

View File

@ -0,0 +1,312 @@
webshims.register('form-message', function($, webshims, window, document, undefined, options){
"use strict";
if(options.lazyCustomMessages){
options.customMessages = true;
}
var validityMessages = webshims.validityMessages;
var implementProperties = options.customMessages ? ['customValidationMessage'] : [];
validityMessages.en = $.extend(true, {
typeMismatch: {
defaultMessage: 'Please enter a valid value.',
email: 'Please enter an email address.',
url: 'Please enter a URL.'
},
badInput: {
defaultMessage: 'Please enter a valid value.',
number: 'Please enter a number.',
date: 'Please enter a date.',
time: 'Please enter a time.',
range: 'Invalid input.',
month: 'Please enter a valid value.',
"datetime-local": 'Please enter a datetime.'
},
rangeUnderflow: {
defaultMessage: 'Value must be greater than or equal to {%min}.'
},
rangeOverflow: {
defaultMessage: 'Value must be less than or equal to {%max}.'
},
stepMismatch: 'Invalid input.',
tooLong: 'Please enter at most {%maxlength} character(s). You entered {%valueLen}.',
tooShort: 'Please enter at least {%minlength} character(s). You entered {%valueLen}.',
patternMismatch: 'Invalid input. {%title}',
valueMissing: {
defaultMessage: 'Please fill out this field.',
checkbox: 'Please check this box if you want to proceed.'
}
}, (validityMessages.en || validityMessages['en-US'] || {}));
if(typeof validityMessages['en'].valueMissing == 'object'){
['select', 'radio'].forEach(function(type){
validityMessages.en.valueMissing[type] = validityMessages.en.valueMissing[type] || 'Please select an option.';
});
}
if(typeof validityMessages.en.rangeUnderflow == 'object'){
['date', 'time', 'datetime-local', 'month'].forEach(function(type){
validityMessages.en.rangeUnderflow[type] = validityMessages.en.rangeUnderflow[type] || 'Value must be at or after {%min}.';
});
}
if(typeof validityMessages.en.rangeOverflow == 'object'){
['date', 'time', 'datetime-local', 'month'].forEach(function(type){
validityMessages.en.rangeOverflow[type] = validityMessages.en.rangeOverflow[type] || 'Value must be at or before {%max}.';
});
}
if(!validityMessages['en-US']){
validityMessages['en-US'] = $.extend(true, {}, validityMessages.en);
}
if(!validityMessages['en-GB']){
validityMessages['en-GB'] = $.extend(true, {}, validityMessages.en);
}
if(!validityMessages['en-AU']){
validityMessages['en-AU'] = $.extend(true, {}, validityMessages.en);
}
validityMessages[''] = validityMessages[''] || validityMessages['en-US'];
validityMessages.de = $.extend(true, {
typeMismatch: {
defaultMessage: '{%value} ist in diesem Feld nicht zulässig.',
email: '{%value} ist keine gültige E-Mail-Adresse.',
url: '{%value} ist kein(e) gültige(r) Webadresse/Pfad.'
},
badInput: {
defaultMessage: 'Geben Sie einen zulässigen Wert ein.',
number: 'Geben Sie eine Nummer ein.',
date: 'Geben Sie ein Datum ein.',
time: 'Geben Sie eine Uhrzeit ein.',
month: 'Geben Sie einen Monat mit Jahr ein.',
range: 'Geben Sie eine Nummer.',
"datetime-local": 'Geben Sie ein Datum mit Uhrzeit ein.'
},
rangeUnderflow: {
defaultMessage: '{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.'
},
rangeOverflow: {
defaultMessage: '{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.'
},
stepMismatch: 'Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}',
tooLong: 'Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.',
tooShort: 'Der eingegebene Text ist zu kurz! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%minlength} das Minimum.',
patternMismatch: '{%value} hat für dieses Eingabefeld ein falsches Format. {%title}',
valueMissing: {
defaultMessage: 'Bitte geben Sie einen Wert ein.',
checkbox: 'Bitte aktivieren Sie das Kästchen.'
}
}, (validityMessages.de || {}));
if(typeof validityMessages.de.valueMissing == 'object'){
['select', 'radio'].forEach(function(type){
validityMessages.de.valueMissing[type] = validityMessages.de.valueMissing[type] || 'Bitte wählen Sie eine Option aus.';
});
}
if(typeof validityMessages.de.rangeUnderflow == 'object'){
['date', 'time', 'datetime-local', 'month'].forEach(function(type){
validityMessages.de.rangeUnderflow[type] = validityMessages.de.rangeUnderflow[type] || '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
});
}
if(typeof validityMessages.de.rangeOverflow == 'object'){
['date', 'time', 'datetime-local', 'month'].forEach(function(type){
validityMessages.de.rangeOverflow[type] = validityMessages.de.rangeOverflow[type] || '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
});
}
var currentValidationMessage = validityMessages[''];
var getMessageFromObj = function(message, elem){
if(message && typeof message !== 'string'){
message = message[ $.prop(elem, 'type') ] || message[ (elem.nodeName || '').toLowerCase() ] || message[ 'defaultMessage' ];
}
return message || '';
};
var lReg = /</g;
var gReg = />/g;
var valueVals = {
value: 1,
min: 1,
max: 1
};
var toLocale = (function(){
var monthFormatter;
var transforms = {
number: function(val){
var num = val * 1;
if(num.toLocaleString && !isNaN(num)){
val = num.toLocaleString() || val;
}
return val;
}
};
var _toLocale = function(val, elem, attr){
var type, widget;
if(valueVals[attr]){
type = $.prop(elem, 'type');
widget = $(elem).getShadowElement().data('wsWidget'+ type );
if(widget && widget.formatValue){
val = widget.formatValue(val, false);
} else if(transforms[type]){
val = transforms[type](val);
}
}
return val;
};
[{n: 'date', f: 'toLocaleDateString'}, {n: 'time', f: 'toLocaleTimeString'}, {n: 'datetime-local', f: 'toLocaleString'}].forEach(function(desc){
transforms[desc.n] = function(val){
var date = new Date(val);
if(date && date[desc.f]){
val = date[desc.f]() || val;
}
return val;
};
});
if(window.Intl && Intl.DateTimeFormat){
monthFormatter = new Intl.DateTimeFormat(navigator.browserLanguage || navigator.language, {year: "numeric", month: "2-digit"}).format(new Date());
if(monthFormatter && monthFormatter.format){
transforms.month = function(val){
var date = new Date(val);
if(date){
val = monthFormatter.format(date) || val;
}
return val;
};
}
}
webshims.format = {};
['date', 'number', 'month', 'time', 'datetime-local'].forEach(function(name){
webshims.format[name] = function(val, opts){
if(opts && opts.nodeType){
return _toLocale(val, opts, name);
}
if(name == 'number' && opts && opts.toFixed ){
val = (val * 1);
if(!opts.fixOnlyFloat || val % 1){
val = val.toFixed(opts.toFixed);
}
}
if(webshims._format && webshims._format[name]){
return webshims._format[name](val, opts);
}
return transforms[name](val);
};
});
return _toLocale;
})();
webshims.replaceValidationplaceholder = function(elem, message, name){
var val = $.prop(elem, 'title');
if(message){
if(name == 'patternMismatch' && !val){
webshims.error('no title for patternMismatch provided. Always add a title attribute.');
}
if(val){
val = '<span class="ws-titlevalue">'+ val.replace(lReg, '&lt;').replace(gReg, '&gt;') +'</span>';
}
if(message.indexOf('{%title}') != -1){
message = message.replace('{%title}', val);
} else if(val) {
message = message+' '+val;
}
}
if(message && message.indexOf('{%') != -1){
['value', 'min', 'max', 'maxlength', 'minlength', 'label'].forEach(function(attr){
if(message.indexOf('{%'+attr) === -1){return;}
var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr) || $.attr(elem, attr) || '') || '';
val = ''+val;
val = toLocale(val, elem, attr);
message = message.replace('{%'+ attr +'}', val.replace(lReg, '&lt;').replace(gReg, '&gt;'));
if('value' == attr){
message = message.replace('{%valueLen}', val.length);
}
});
}
return message;
};
webshims.createValidationMessage = function(elem, name){
var message = getMessageFromObj(currentValidationMessage[name], elem);
if(!message && name == 'badInput'){
message = getMessageFromObj(currentValidationMessage.typeMismatch, elem);
}
if(!message && name == 'typeMismatch'){
message = getMessageFromObj(currentValidationMessage.badInput, elem);
}
if(!message){
message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
if(name != 'customError'){
webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+webshims.activeLang());
}
}
message = webshims.replaceValidationplaceholder(elem, message, name);
return message || '';
};
if(!webshims.support.formvalidation || webshims.bugs.bustedValidity){
implementProperties.push('validationMessage');
}
currentValidationMessage = webshims.activeLang(validityMessages);
$(validityMessages).on('change', function(e, data){
currentValidationMessage = validityMessages.__active;
});
implementProperties.forEach(function(messageProp){
webshims.defineNodeNamesProperty(['fieldset', 'output', 'button'], messageProp, {
prop: {
value: '',
writeable: false
}
});
['input', 'select', 'textarea'].forEach(function(nodeName){
var desc = webshims.defineNodeNameProperty(nodeName, messageProp, {
prop: {
get: function(){
var elem = this;
var message = '';
if(!$.prop(elem, 'willValidate')){
return message;
}
var validity = $.prop(elem, 'validity') || {valid: 1};
if(validity.valid){return message;}
message = webshims.getContentValidationMessage(elem, validity);
if(message){return message;}
if(validity.customError && elem.nodeName){
message = (webshims.support.formvalidation && !webshims.bugs.bustedValidity && desc.prop._supget) ? desc.prop._supget.call(elem) : webshims.data(elem, 'customvalidationMessage');
if(message){return message;}
}
$.each(validity, function(name, prop){
if(name == 'valid' || !prop){return;}
message = webshims.createValidationMessage(elem, name);
if(message){
return false;
}
});
return message || '';
},
writeable: false
}
});
});
});
});

View File

@ -0,0 +1,211 @@
webshims.register('form-native-extend', function($, webshims, window, doc, undefined, options){
"use strict";
var support = webshims.support;
if(!support.formvalidation || webshims.bugs.bustedValidity){return;}
var typeModels = webshims.inputTypes;
var runTest = false;
var validityRules = {};
var updateValidity = (function(){
var timer;
var getValidity = function(){
$(this).prop('validity');
};
var update = function(){
$('input').each(getValidity);
};
return function(){
clearTimeout(timer);
timer = setTimeout(update, 9);
};
})();
webshims.addInputType = function(type, obj){
typeModels[type] = obj;
runTest = true;
//update validity of all implemented input types
if($.isDOMReady && support.formvalidation && !webshims.bugs.bustedValidity){
updateValidity();
}
};
webshims.addValidityRule = function(type, fn){
validityRules[type] = fn;
};
$.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
webshims.addValidityRule(name, function (input, val, cache, validityState){
if(val === ''){return false;}
var ret = validityState[name];
if(!('type' in cache)){
cache.type = (input[0].getAttribute('type') || '').toLowerCase();
}
if(typeModels[cache.type] && typeModels[cache.type][fn]){
ret = typeModels[cache.type][fn](val, input);
}
return ret || false;
});
});
var formsExtModule = webshims.modules['form-number-date-api'];
var overrideValidity = formsExtModule.loaded && !formsExtModule.test();
var validityProps = ['customError', 'badInput','typeMismatch','rangeUnderflow','rangeOverflow','stepMismatch','tooLong', 'tooShort','patternMismatch','valueMissing','valid'];
var validityChanger = ['value'];
var validityElements = [];
var testValidity = function(elem, init){
if(!elem && !runTest){return;}
var type = (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase();
if(typeModels[type]){
$.prop(elem, 'validity');
}
};
var oldSetCustomValidity = {};
['input', 'textarea', 'select'].forEach(function(name){
var desc = webshims.defineNodeNameProperty(name, 'setCustomValidity', {
prop: {
value: function(error){
error = error+'';
var elem = (name == 'input') ? $(this).getNativeElement()[0] : this;
desc.prop._supvalue.call(elem, error);
if(overrideValidity){
webshims.data(elem, 'hasCustomError', !!(error));
testValidity(elem);
}
}
}
});
oldSetCustomValidity[name] = desc.prop._supvalue;
});
if(overrideValidity){
validityChanger.push('min');
validityChanger.push('max');
validityChanger.push('step');
validityElements.push('input');
}
if(overrideValidity){
var stopValidity;
validityElements.forEach(function(nodeName){
var oldDesc = webshims.defineNodeNameProperty(nodeName, 'validity', {
prop: {
get: function(){
if(stopValidity){return;}
var elem = (nodeName == 'input') ? $(this).getNativeElement()[0] : this;
var validity = oldDesc.prop._supget.call(elem);
if(!validity){
return validity;
}
var validityState = {};
validityProps.forEach(function(prop){
validityState[prop] = validity[prop] || false;
});
if( !$.prop(elem, 'willValidate') ){
return validityState;
}
stopValidity = true;
var jElm = $(elem),
cache = {type: (elem.getAttribute && elem.getAttribute('type') || elem.type || '').toLowerCase(), nodeName: (elem.nodeName || '').toLowerCase()},
val = jElm.val(),
customError = !!(webshims.data(elem, 'hasCustomError')),
setCustomMessage
;
stopValidity = false;
validityState.customError = customError;
if( validityState.valid && validityState.customError ){
validityState.valid = false;
} else if(!validityState.valid) {
var allFalse = true;
$.each(validityState, function(name, prop){
if(prop){
allFalse = false;
return false;
}
});
if(allFalse){
validityState.valid = true;
}
}
$.each(validityRules, function(rule, fn){
validityState[rule] = fn(jElm, val, cache, validityState);
if( validityState[rule] && (validityState.valid || !setCustomMessage) && ((typeModels[cache.type])) ) {
oldSetCustomValidity[nodeName].call(elem, webshims.createValidationMessage(elem, rule));
validityState.valid = false;
setCustomMessage = true;
}
});
if(validityState.valid){
oldSetCustomValidity[nodeName].call(elem, '');
webshims.data(elem, 'hasCustomError', false);
}
return validityState;
},
writeable: false
}
});
});
validityChanger.forEach(function(prop){
webshims.onNodeNamesPropertyModify(validityElements, prop, function(s){
testValidity(this);
});
});
if(doc.addEventListener){
var inputThrottle;
var testPassValidity = function(e){
if(!('form' in e.target)){return;}
clearTimeout(inputThrottle);
testValidity(e.target);
};
doc.addEventListener('change', testPassValidity, true);
doc.addEventListener('input', function(e){
clearTimeout(inputThrottle);
inputThrottle = setTimeout(function(){
testValidity(e.target);
}, 290);
}, true);
}
var validityElementsSel = validityElements.join(',');
webshims.addReady(function(context, elem){
if(runTest){
$(validityElementsSel, context).add(elem.filter(validityElementsSel)).each(function(){
testValidity(this);
});
}
});
} //end: overrideValidity
webshims.defineNodeNameProperty('input', 'type', {
prop: {
get: function(){
var elem = this;
var type = (elem.getAttribute && elem.getAttribute('type') || '').toLowerCase();
return (webshims.inputTypes[type]) ? type : elem.type;
}
}
});
});

View File

@ -0,0 +1,617 @@
webshims.register('form-number-date-api', function($, webshims, window, document, undefined, options){
"use strict";
if(!webshims.addInputType){
webshims.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')");
}
if(!webshims.getStep){
webshims.getStep = function(elem, type){
var step = $.attr(elem, 'step');
if(step === 'any'){
return step;
}
type = type || getType(elem);
if(!typeModels[type] || !typeModels[type].step){
return step;
}
step = typeProtos.number.asNumber(step);
return ((!isNaN(step) && step > 0) ? step : typeModels[type].step) * (typeModels[type].stepScaleFactor || 1);
};
}
if(!webshims.addMinMaxNumberToCache){
webshims.addMinMaxNumberToCache = function(attr, elem, cache){
if (!(attr+'AsNumber' in cache)) {
cache[attr+'AsNumber'] = typeModels[cache.type].asNumber(elem.attr(attr));
if(isNaN(cache[attr+'AsNumber']) && (attr+'Default' in typeModels[cache.type])){
cache[attr+'AsNumber'] = typeModels[cache.type][attr+'Default'];
}
}
};
}
var nan = parseInt('NaN', 10),
doc = document,
typeModels = webshims.inputTypes,
isNumber = function(string){
return (typeof string == 'number' || (string && string == string * 1));
},
supportsType = function(type){
return ($('<input type="'+type+'" />').prop('type') === type);
},
getType = function(elem){
return (elem.getAttribute('type') || '').toLowerCase();
},
isDateTimePart = function(string){
return (string && !(isNaN(string * 1)));
},
addMinMaxNumberToCache = webshims.addMinMaxNumberToCache,
addleadingZero = function(val, len){
val = ''+val;
len = len - val.length;
for(var i = 0; i < len; i++){
val = '0'+val;
}
return val;
},
EPS = 1e-7,
typeBugs = webshims.bugs.bustedValidity
;
webshims.addValidityRule('stepMismatch', function(input, val, cache, validityState){
if(val === ''){return false;}
if(!('type' in cache)){
cache.type = getType(input[0]);
}
if(cache.type == 'week'){return false;}
var base, attrVal;
var ret = (validityState || {}).stepMismatch || false;
if(typeModels[cache.type] && typeModels[cache.type].step){
if( !('step' in cache) ){
cache.step = webshims.getStep(input[0], cache.type);
}
if(cache.step == 'any'){return false;}
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){return false;}
addMinMaxNumberToCache('min', input, cache);
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = input.prop('defaultValue'))){
base = typeModels[cache.type].asNumber( attrVal );
}
if(isNaN(base)){
base = typeModels[cache.type].stepBase || 0;
}
ret = Math.abs((cache.valueAsNumber - base) % cache.step);
ret = !( ret <= EPS || Math.abs(ret - cache.step) <= EPS );
}
return ret;
});
[{name: 'rangeOverflow', attr: 'max', factor: 1}, {name: 'rangeUnderflow', attr: 'min', factor: -1}].forEach(function(data, i){
webshims.addValidityRule(data.name, function(input, val, cache, validityState) {
var ret = (validityState || {})[data.name] || false;
if(val === ''){return ret;}
if (!('type' in cache)) {
cache.type = getType(input[0]);
}
if (typeModels[cache.type] && typeModels[cache.type].asNumber) {
if(!('valueAsNumber' in cache)){
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
}
if(isNaN(cache.valueAsNumber)){
return false;
}
addMinMaxNumberToCache(data.attr, input, cache);
if(isNaN(cache[data.attr+'AsNumber'])){
return ret;
}
ret = ( cache[data.attr+'AsNumber'] * data.factor < cache.valueAsNumber * data.factor - EPS );
}
return ret;
});
});
webshims.reflectProperties(['input'], ['max', 'min', 'step']);
//IDLs and methods, that aren't part of constrain validation, but strongly tight to it
var valueAsNumberDescriptor = webshims.defineNodeNameProperty('input', 'valueAsNumber', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
var ret = (typeModels[type] && typeModels[type].asNumber) ?
typeModels[type].asNumber($.prop(elem, 'value')) :
(valueAsNumberDescriptor.prop._supget && valueAsNumberDescriptor.prop._supget.apply(elem, arguments));
if(ret == null){
ret = nan;
}
return ret;
},
set: function(val){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].numberToString){
//is NaN a number?
if(isNaN(val)){
$.prop(elem, 'value', '');
return;
}
var set = typeModels[type].numberToString(val);
if(set !== false){
$.prop(elem, 'value', set);
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else if(valueAsNumberDescriptor.prop._supset) {
valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
}
}
}
});
var valueAsDateDescriptor = webshims.defineNodeNameProperty('input', 'valueAsDate', {
prop: {
get: function(){
var elem = this;
var type = getType(elem);
return (typeModels[type] && typeModels[type].asDate && !typeModels[type].noAsDate) ?
typeModels[type].asDate($.prop(elem, 'value')) :
valueAsDateDescriptor.prop._supget && valueAsDateDescriptor.prop._supget.call(elem) || null;
},
set: function(value){
var elem = this;
var type = getType(elem);
if(typeModels[type] && typeModels[type].dateToString && !typeModels[type].noAsDate){
if(value === null){
$.prop(elem, 'value', '');
return '';
}
var set = typeModels[type].dateToString(value);
if(set !== false){
$.prop(elem, 'value', set);
return set;
} else {
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
}
} else {
return valueAsDateDescriptor.prop._supset && valueAsDateDescriptor.prop._supset.apply(elem, arguments) || null;
}
}
}
});
$.each({stepUp: 1, stepDown: -1}, function(name, stepFactor){
var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
prop: {
value: function(factor){
var step, val, valModStep, alignValue, cache, base, attrVal;
var type = getType(this);
if(typeModels[type] && typeModels[type].asNumber){
cache = {type: type};
if(!factor){
factor = 1;
webshims.warn("you should always use a factor for stepUp/stepDown");
}
factor *= stepFactor;
step = webshims.getStep(this, type);
if(step == 'any'){
webshims.info("step is 'any' can't apply stepUp/stepDown");
throw('invalid state error');
}
webshims.addMinMaxNumberToCache('min', $(this), cache);
webshims.addMinMaxNumberToCache('max', $(this), cache);
val = $.prop(this, 'valueAsNumber');
if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
$.prop(this, 'valueAsNumber', cache.minAsNumber);
return;
} else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
$.prop(this, 'valueAsNumber', cache.maxAsNumber);
return;
}
if(isNaN(val)){
val = 0;
}
base = cache.minAsNumber;
if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
base = typeModels[type].asNumber( attrVal );
}
if(!base){
base = 0;
}
step *= factor;
val = (val + step).toFixed(5) * 1;
valModStep = (val - base) % step;
if ( valModStep && (Math.abs(valModStep) > EPS) ) {
alignValue = val - valModStep;
alignValue += ( valModStep > 0 ) ? step : ( -step );
val = alignValue.toFixed(5) * 1;
}
if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
webshims.info("max/min overflow can't apply stepUp/stepDown");
return;
}
$.prop(this, 'valueAsNumber', val);
} else if(stepDescriptor.prop && stepDescriptor.prop._supvalue){
return stepDescriptor.prop._supvalue.apply(this, arguments);
} else {
webshims.info("no step method for type: "+ type);
throw('invalid state error');
}
}
}
});
});
/*
* ToDO: WEEK
*/
// var getWeek = function(date){
// var time;
// var checkDate = new Date(date.getTime());
//
// checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
//
// time = checkDate.getTime();
// checkDate.setMonth(0);
// checkDate.setDate(1);
// return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
// };
//
// var setWeek = function(year, week){
// var date = new Date(year, 0, 1);
//
// week = (week - 1) * 86400000 * 7;
// date = new Date(date.getTime() + week);
// date.setDate(date.getDate() + 1 - (date.getDay() || 7));
// return date;
// };
var typeProtos = {
number: {
bad: function(val){
return !(isNumber(val));
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 1,
asNumber: function(str){
return (isNumber(str)) ? str * 1 : nan;
},
numberToString: function(num){
return (isNumber(num)) ? num : false;
}
},
range: {
minDefault: 0,
maxDefault: 100
},
color: {
bad: (function(){
var cReg = /^\u0023[a-f0-9]{6}$/;
return function(val){
return (!val || val.length != 7 || !(cReg.test(val)));
};
})()
},
date: {
bad: function(val){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
var i;
var valA = val.split(/\u002D/);
if(valA.length !== 3){return true;}
var ret = false;
if(valA[0].length < 4 || valA[1].length != 2 || valA[1] > 12 || valA[2].length != 2 || valA[2] > 33){
ret = true;
} else {
for(i = 0; i < 3; i++){
if(!isDateTimePart(valA[i])){
ret = true;
break;
}
}
}
return ret || (val !== this.dateToString( this.asDate(val, true) ) );
},
step: 1,
//stepBase: 0, 0 = default
stepScaleFactor: 86400000,
asDate: function(val, _noMismatch){
if(!_noMismatch && this.bad(val)){
return null;
}
return new Date(this.asNumber(val, true));
},
asNumber: function(str, _noMismatch){
var ret = nan;
if(_noMismatch || !this.bad(str)){
str = str.split(/\u002D/);
ret = Date.UTC(str[0], str[1] - 1, str[2]);
}
return ret;
},
numberToString: function(num){
return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
},
dateToString: function(date){
return (date && date.getFullYear) ? addleadingZero(date.getUTCFullYear(), 4) +'-'+ addleadingZero(date.getUTCMonth()+1, 2) +'-'+ addleadingZero(date.getUTCDate(), 2) : false;
}
},
/*
* ToDO: WEEK
*/
// week: {
// bad: function(val){
// if(!val || !val.split){return true;}
// var valA = val.split('-W');
// var ret = true;
// if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){
// ret = this.dateToString(setWeek(valA[0], valA[1])) != val;
// }
// return ret;
// },
// step: 1,
// stepScaleFactor: 604800000,
// stepBase: -259200000,
// asDate: function(str, _noMismatch){
// var ret = null;
// if(_noMismatch || !this.bad(str)){
// ret = str.split('-W');
// ret = setWeek(ret[0], ret[1]);
// }
// return ret;
// },
// asNumber: function(str, _noMismatch){
// var ret = nan;
// var date = this.asDate(str, _noMismatch);
// if(date && date.getUTCFullYear){
// ret = date.getTime();
// }
// return ret;
// },
// dateToString: function(date){
// var week, checkDate;
// var ret = false;
// if(date && date.getFullYear){
// week = getWeek(date);
// if(week == 1){
// checkDate = new Date(date.getTime());
// checkDate.setDate(checkDate.getDate() + 7);
// date.setUTCFullYear(checkDate.getUTCFullYear());
// }
// ret = addleadingZero(date.getUTCFullYear(), 4) +'-W'+addleadingZero(week, 2);
// }
// return ret;
// },
// numberToString: function(num){
// return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
// }
// },
time: {
bad: function(val, _getParsed){
if(!val || !val.split || !(/\d$/.test(val))){return true;}
val = val.split(/\u003A/);
if(val.length < 2 || val.length > 3){return true;}
var ret = false,
sFraction;
if(val[2]){
val[2] = val[2].split(/\u002E/);
sFraction = parseInt(val[2][1], 10);
val[2] = val[2][0];
}
$.each(val, function(i, part){
if(!isDateTimePart(part) || part.length !== 2){
ret = true;
return false;
}
});
if(ret){return true;}
if(val[0] > 23 || val[0] < 0 || val[1] > 59 || val[1] < 0){
return true;
}
if(val[2] && (val[2] > 59 || val[2] < 0 )){
return true;
}
if(sFraction && isNaN(sFraction)){
return true;
}
if(sFraction){
if(sFraction < 100){
sFraction *= 100;
} else if(sFraction < 10){
sFraction *= 10;
}
}
return (_getParsed === true) ? [val, sFraction] : false;
},
step: 60,
stepBase: 0,
stepScaleFactor: 1000,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
val = this.bad(val, true);
if(val !== true){
ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
if(val[1]){
ret += val[1];
}
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = addleadingZero(date.getUTCHours(), 2) +':'+ addleadingZero(date.getUTCMinutes(), 2),
tmp = date.getSeconds()
;
if(tmp != "0"){
str += ':'+ addleadingZero(tmp, 2);
}
tmp = date.getUTCMilliseconds();
if(tmp != "0"){
str += '.'+ addleadingZero(tmp, 3);
}
return str;
} else {
return false;
}
}
},
month: {
bad: function(val){
return typeProtos.date.bad(val+'-01');
},
step: 1,
stepScaleFactor: false,
//stepBase: 0, 0 = default
asDate: function(val){
return new Date(typeProtos.date.asNumber(val+'-01'));
},
asNumber: function(val){
//1970-01
var ret = nan;
if(val && !this.bad(val)){
val = val.split(/\u002D/);
val[0] = (val[0] * 1) - 1970;
val[1] = (val[1] * 1) - 1;
ret = (val[0] * 12) + val[1];
}
return ret;
},
numberToString: function(num){
var mod;
var ret = false;
if(isNumber(num)){
mod = (num % 12);
num = ((num - mod) / 12) + 1970;
mod += 1;
if(mod < 1){
num -= 1;
mod += 12;
}
ret = addleadingZero(num, 4)+'-'+addleadingZero(mod, 2);
}
return ret;
},
dateToString: function(date){
if(date && date.getUTCHours){
var str = typeProtos.date.dateToString(date);
return (str.split && (str = str.split(/\u002D/))) ? str[0]+'-'+str[1] : false;
} else {
return false;
}
}
}
,'datetime-local': {
bad: function(val, _getParsed){
if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
val = val.split(/\u0054/);
return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
},
noAsDate: true,
asDate: function(val){
val = new Date(this.asNumber(val));
return (isNaN(val)) ? null : val;
},
asNumber: function(val){
var ret = nan;
var time = this.bad(val, true);
if(time !== true){
val = val.split(/\u0054/)[0].split(/\u002D/);
ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
if(time[1]){
ret += time[1];
}
}
return ret;
},
dateToString: function(date, _getParsed){
return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
}
}
};
if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
}
//
['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
if(typeBugs || !supportsType(type)){
webshims.addInputType(type, typeProtos[type]);
}
});
if($('<input />').prop('labels') == null){
webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
prop: {
get: function(){
if(this.type == 'hidden'){return null;}
var id = this.id;
var labels = $(this)
.closest('label')
.filter(function(){
var hFor = (this.attributes['for'] || {});
return (!hFor.specified || hFor.value == id);
})
;
if(id) {
labels = labels.add('label[for="'+ id +'"]');
}
return labels.get();
},
writeable: false
}
});
}
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,807 @@
webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
"use strict";
webshims.inputTypes = webshims.inputTypes || {};
//some helper-functions
var cfg = webshims.cfg.forms;
var bugs = webshims.bugs;
var splitReg = /\s*,\s*/g;
var typeModels = webshims.inputTypes,
checkTypes = {
radio: 1,
checkbox: 1
},
getType = function(){
var elem = this;
var type = (elem.getAttribute('type') || '').toLowerCase();
return (webshims.inputTypes[type]) ? type : elem.type;
},
cacheType = function(cache, input){
if(!('type' in cache)){
cache.type = getType.call(input);
}
}
;
(function(){
if('querySelector' in document){
try {
bugs.findRequired = !($('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /></form>')[0].querySelector('select:required'));
} catch(er){
bugs.findRequired = false;
}
if (bugs.bustedValidity || bugs.findRequired) {
(function(){
var find = $.find;
var matchesSelector = $.find.matchesSelector;
var regExp = /(\:valid|\:invalid|\:optional|\:required)(?=[\s\[\~\.\+\>\:\#*]|$)/ig;
var regFn = function(sel){
return sel + '-element';
};
$.find = (function(){
var slice = Array.prototype.slice;
var fn = function(sel){
var ar = arguments;
ar = slice.call(ar, 1, ar.length);
ar.unshift(sel.replace(regExp, regFn));
return find.apply(this, ar);
};
for (var i in find) {
if(find.hasOwnProperty(i)){
fn[i] = find[i];
}
}
return fn;
})();
$.find.matchesSelector = function(node, expr){
expr = expr.replace(regExp, regFn);
return matchesSelector.call(this, node, expr);
};
})();
}
}
})();
//API to add new input types
webshims.addInputType = function(type, obj){
typeModels[type] = obj;
};
//contsrain-validation-api
var validityPrototype = {
customError: false,
typeMismatch: false,
badInput: false,
rangeUnderflow: false,
rangeOverflow: false,
stepMismatch: false,
tooLong: false,
tooShort: false,
patternMismatch: false,
valueMissing: false,
valid: true
};
var isPlaceholderOptionSelected = function(select){
if(select.type == 'select-one' && select.size < 2){
var option = $('> option:first-child', select);
return !!option.prop('selected');
}
return false;
};
var emptyJ = $([]);
//TODO: cache + perftest
var getGroupElements = function(elem){
elem = $(elem);
var name, form;
var ret = emptyJ;
if(elem[0].type == 'radio'){
name = elem[0].name;
if(!name){
ret = elem;
} else {
form = elem.prop('form');
ret = $(document.getElementsByName(name)).filter(function(){
return this.type == 'radio' && $.prop(this, 'form') == form && this.name == name;
});
}
}
return ret;
};
var patternTypes = {url: 1, email: 1, text: 1, search: 1, tel: 1, password: 1};
var lengthTypes = $.extend({textarea: 1}, patternTypes);
var validityRules = {
valueMissing: function(input, val, cache){
if(!input.prop('required')){return false;}
var ret = false;
cacheType(cache, input[0]);
if(cache.nodeName == 'select'){
ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
} else if(checkTypes[cache.type]){
ret = (cache.type == 'checkbox') ? !input.is(':checked') : !getGroupElements(input).filter(':checked')[0];
} else {
ret = !(val);
}
return ret;
},
patternMismatch: function(input, val, cache) {
var i;
var ret = false;
if(val === '' || cache.nodeName == 'select'){return ret;}
cacheType(cache, input[0]);
if(!patternTypes[cache.type]){return ret;}
var pattern = input.attr('pattern');
if(!pattern){return ret;}
try {
pattern = new RegExp('^(?:' + pattern + ')$');
} catch(er){
webshims.error('invalid pattern value: "'+ pattern +'" | '+ er);
pattern = ret;
}
if(!pattern){return ret;}
val = cache.type == 'email' && input.prop('multiple') ? val.split(splitReg) : [val];
for(i = 0; i < val.length; i++){
if(!pattern.test(val[i])){
ret = true;
break;
}
}
return ret;
}
}
;
$.each({tooShort: ['minLength', -1], tooLong: ['maxLength', 1]}, function(name, props){
validityRules[name] = function(input, val, cache){
//defaultValue is not the same as dirty flag, but very similiar
if(cache.nodeName == 'select' || input.prop('defaultValue') == val){return false;}
cacheType(cache, input[0]);
if(!lengthTypes[cache.type]){return false;}
var prop = input.prop(props[0]);
return ( prop > 0 && prop * props[1] < val.length * props[1] );
};
});
$.each({typeMismatch: 'mismatch', badInput: 'bad'}, function(name, fn){
validityRules[name] = function (input, val, cache){
if(val === '' || cache.nodeName == 'select'){return false;}
var ret = false;
cacheType(cache, input[0]);
if(typeModels[cache.type] && typeModels[cache.type][fn]){
ret = typeModels[cache.type][fn](val, input);
} else if('validity' in input[0] && ('name' in input[0].validity)){
ret = input[0].validity[name] || false;
}
return ret;
};
});
webshims.modules["form-core"].getGroupElements = getGroupElements;
webshims.addValidityRule = function(type, fn){
validityRules[type] = fn;
};
$.event.special.invalid = {
add: function(){
$.event.special.invalid.setup.call(this.form || this);
},
setup: function(){
var form = this.form || this;
if( $.data(form, 'invalidEventShim') ){
form = null;
return;
}
$(form)
.data('invalidEventShim', true)
.on('submit', $.event.special.invalid.handler)
;
webshims.moveToFirstEvent(form, 'submit');
if(webshims.bugs.bustedValidity && $.nodeName(form, 'form')){
(function(){
var noValidate = form.getAttribute('novalidate');
form.setAttribute('novalidate', 'novalidate');
webshims.data(form, 'bustedNoValidate', (noValidate == null) ? null : noValidate);
})();
}
form = null;
},
teardown: $.noop,
handler: function(e, d){
if( e.type != 'submit' || e.testedValidity || !e.originalEvent || !$.nodeName(e.target, 'form') || $.prop(e.target, 'noValidate') ){return;}
e.testedValidity = true;
var notValid = !($(e.target).callProp('reportValidity'));
if(notValid){
e.stopImmediatePropagation();
if(!options.noFormInvalid){
$(e.target).trigger('invalid');
}
return false;
}
}
};
$.event.special.submit = $.event.special.submit || {setup: function(){return false;}};
var submitSetup = $.event.special.submit.setup;
$.extend($.event.special.submit, {
setup: function(){
if($.nodeName(this, 'form')){
$(this).on('invalid', $.noop);
} else {
$('form', this).on('invalid', $.noop);
}
return submitSetup.apply(this, arguments);
}
});
webshims.ready('form-shim-extend2 WINDOWLOAD', function(){
$(window).on('invalid', $.noop);
});
webshims.addInputType('email', {
mismatch: (function(){
//taken from http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
var test = cfg.emailReg || /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
return function(val, input){
var i;
var ret = false;
if(val){
val = input.prop('multiple') ? val.split(splitReg) : [val];
for(i = 0; i < val.length; i++){
if(!test.test(val[i])){
ret = true;
break;
}
}
}
return ret;
};
})()
});
webshims.addInputType('url', {
mismatch: (function(){
//taken from scott gonzales
var test = cfg.urlReg || /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
return function(val){
return val && !test.test(val);
};
})()
});
webshims.defineNodeNameProperty('input', 'type', {
prop: {
get: getType
}
});
// IDLs for constrain validation API
//ToDo: add object to this list
webshims.defineNodeNamesProperties(['button', 'fieldset', 'output'], {
checkValidity: {
value: function(){return true;}
},
reportValidity: {
value: function(){return true;}
},
willValidate: {
value: false
},
setCustomValidity: {
value: $.noop
},
validity: {
writeable: false,
get: function(){
return $.extend({}, validityPrototype);
}
}
}, 'prop');
var baseCheckValidity = function(elem, type){
var e,
v = $.prop(elem, 'validity')
;
if(v){
$.data(elem, 'cachedValidity', v);
} else {
return true;
}
if( !v.valid ){
e = $.Event('invalid');
var jElm = $(elem).trigger(e);
if(type == 'reportValidity' && !baseCheckValidity.unhandledInvalids && !e.isDefaultPrevented()){
webshims.validityAlert.showFor(jElm);
baseCheckValidity.unhandledInvalids = true;
}
}
$.removeData(elem, 'cachedValidity');
return v.valid;
};
var rsubmittable = /^(?:select|textarea|input)/i;
['checkValidity', 'reportValidity'].forEach(function(name){
webshims.defineNodeNameProperty('form', name, {
prop: {
value: function(){
var ret = true,
elems = $($.prop(this, 'elements')).filter(function(){
if(!rsubmittable.test(this.nodeName)){return false;}
var shadowData = webshims.data(this, 'shadowData');
return !shadowData || !shadowData.nativeElement || shadowData.nativeElement === this;
})
;
baseCheckValidity.unhandledInvalids = false;
for(var i = 0, len = elems.length; i < len; i++){
if( !baseCheckValidity(elems[i], name) ){
ret = false;
}
}
return ret;
}
}
});
});
['input', 'textarea', 'select'].forEach(function(nodeName){
var inputValidationAPI = {
setCustomValidity: {
value: function(error){
$.removeData(this, 'cachedValidity');
webshims.data(this, 'customvalidationMessage', ''+error);
if(bugs.bustedValidity && inputValidationAPI.setCustomValidity.prop._supvalue){
inputValidationAPI.setCustomValidity.prop._supvalue.apply(this, arguments);
}
}
},
willValidate: {
writeable: false,
get: (function(){
var types = {
button: 1,
reset: 1,
hidden: 1,
image: 1
}
;
return function(){
var elem = $(this).getNativeElement()[0];
return !!(!elem.readOnly && !types[elem.type] && !$(elem).is(':disabled') );
};
})()
},
validity: {
writeable: false,
get: function(){
var jElm = $(this).getNativeElement();
var elem = jElm[0];
var validityState = $.data(elem, 'cachedValidity');
if(validityState){
return validityState;
}
validityState = $.extend({}, validityPrototype);
if( !$.prop(elem, 'willValidate') || elem.type == 'submit' ){
return validityState;
}
var val = jElm.val();
var cache = {nodeName: elem.nodeName.toLowerCase()};
validityState.customError = !!(webshims.data(elem, 'customvalidationMessage'));
if( validityState.customError ){
validityState.valid = false;
}
$.each(validityRules, function(rule, fn){
if (fn(jElm, val, cache)) {
validityState[rule] = true;
validityState.valid = false;
}
});
$(this).getShadowFocusElement().attr('aria-invalid', validityState.valid ? 'false' : 'true');
jElm = null;
elem = null;
return validityState;
}
}
};
['checkValidity', 'reportValidity'].forEach(function(name){
inputValidationAPI[name] = {
value: function(){
baseCheckValidity.unhandledInvalids = false;
return baseCheckValidity($(this).getNativeElement()[0], name);
}
};
});
webshims.defineNodeNameProperties(nodeName, inputValidationAPI, 'prop');
});
webshims.defineNodeNamesBooleanProperty(['input', 'textarea', 'select'], 'required', {
set: function(value){
$(this).getShadowFocusElement().attr('aria-required', !!(value)+'');
},
initAttr: true
});
webshims.defineNodeNamesBooleanProperty(['input'], 'multiple');
if(bugs.bustedValidity){
webshims.defineNodeNameProperty('form', 'novalidate', {
attr: {
set: function(val){
webshims.data(this, 'bustedNoValidate', ''+val);
},
get: function(){
var ret = webshims.data(this, 'bustedNoValidate');
return ret == null ? undefined : ret;
}
},
removeAttr: {
value: function(){
webshims.data(this, 'bustedNoValidate', null);
}
}
});
$.each(['rangeUnderflow', 'rangeOverflow', 'stepMismatch'], function(i, name){
validityRules[name] = function(elem){
return (elem[0].validity || {})[name] || false;
};
});
}
webshims.defineNodeNameProperty('form', 'noValidate', {
prop: {
set: function(val){
val = !!val;
if(val){
$.attr(this, 'novalidate', 'novalidate');
} else {
$(this).removeAttr('novalidate');
}
},
get: function(){
return $.attr(this, 'novalidate') != null;
}
}
});
['minlength', 'minLength'].forEach(function(propName){
webshims.defineNodeNamesProperty(['input', 'textarea'], propName, {
prop: {
set: function(val){
val *= 1;
if(val < 0){
throw('INDEX_SIZE_ERR');
}
this.setAttribute('minlength', val || 0);
},
get: function(){
var val = this.getAttribute('minlength');
return val == null ? -1 : (val * 1) || 0;
}
}
});
});
if(webshims.support.inputtypes.date && /webkit/i.test(navigator.userAgent)){
(function(){
var noInputTriggerEvts = {updateInput: 1, input: 1},
fixInputTypes = {
date: 1,
time: 1,
month: 1,
week: 1,
"datetime-local": 1
},
noFocusEvents = {
focusout: 1,
blur: 1
},
changeEvts = {
updateInput: 1,
change: 1
},
observe = function(input){
var timer,
focusedin = true,
lastInputVal = input.prop('value'),
lastChangeVal = lastInputVal,
trigger = function(e){
//input === null
if(!input){return;}
var newVal = input.prop('value');
if(newVal !== lastInputVal){
lastInputVal = newVal;
if(!e || !noInputTriggerEvts[e.type]){
input.trigger('input');
}
}
if(e && changeEvts[e.type]){
lastChangeVal = newVal;
}
if(!focusedin && newVal !== lastChangeVal){
input.trigger('change');
}
},
extraTimer,
extraTest = function(){
clearTimeout(extraTimer);
extraTimer = setTimeout(trigger, 9);
},
unbind = function(e){
clearInterval(timer);
setTimeout(function(){
if(e && noFocusEvents[e.type]){
focusedin = false;
}
if(input){
input.off('focusout blur', unbind).off('input change updateInput', trigger);
trigger();
}
input = null;
}, 1);
}
;
clearInterval(timer);
timer = setInterval(trigger, 160);
extraTest();
input
.off({
'focusout blur': unbind,
'input change updateInput': trigger
})
.on({
'focusout blur': unbind,
'input updateInput change': trigger
})
;
}
;
$(document)
.on('focusin', function(e){
if( e.target && fixInputTypes[e.target.type] && !e.target.readOnly && !e.target.disabled ){
observe($(e.target));
}
})
;
})();
}
webshims.addReady(function(context, contextElem){
//start constrain-validation
var focusElem;
$('form', context)
.add(contextElem.filter('form'))
.on('invalid', $.noop)
;
try {
if(context == document && !('form' in (document.activeElement || {}))) {
focusElem = $(context.querySelector('input[autofocus], select[autofocus], textarea[autofocus]')).eq(0).getShadowFocusElement()[0];
if (focusElem && focusElem.offsetHeight && focusElem.offsetWidth) {
focusElem.focus();
}
}
}
catch (er) {}
});
if(!webshims.support.datalist){
webshims.defineNodeNameProperty('datalist', 'options', {
prop: {
writeable: false,
get: function(){
var elem = this;
var select = $('select', elem);
var options;
if(select[0]){
options = $.makeArray(select[0].options || []);
} else {
options = elem.getElementsByTagName('option');
if(options.length){
webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
}
}
return options;
}
}
});
}
var submitterTypes = {submit: 1, button: 1, image: 1};
var formSubmitterDescriptors = {};
[
{
name: "enctype",
limitedTo: {
"application/x-www-form-urlencoded": 1,
"multipart/form-data": 1,
"text/plain": 1
},
defaultProp: "application/x-www-form-urlencoded",
proptype: "enum"
},
{
name: "method",
limitedTo: {
"get": 1,
"post": 1
},
defaultProp: "get",
proptype: "enum"
},
{
name: "action",
proptype: "url"
},
{
name: "target"
},
{
name: "novalidate",
propName: "noValidate",
proptype: "boolean"
}
].forEach(function(desc){
var propName = 'form'+ (desc.propName || desc.name).replace(/^[a-z]/, function(f){
return f.toUpperCase();
});
var attrName = 'form'+ desc.name;
var formName = desc.name;
var eventName = 'click.webshimssubmittermutate'+formName;
var changeSubmitter = function(){
var elem = this;
if( !('form' in elem) || !submitterTypes[elem.type] ){return;}
var form = $.prop(elem, 'form');
if(!form){return;}
var attr = $.attr(elem, attrName);
if(attr != null && ( !desc.limitedTo || attr.toLowerCase() === $.prop(elem, propName))){
var oldAttr = $.attr(form, formName);
$.attr(form, formName, attr);
setTimeout(function(){
if(oldAttr != null){
$.attr(form, formName, oldAttr);
} else {
try {
$(form).removeAttr(formName);
} catch(er){
form.removeAttribute(formName);
}
}
}, 9);
}
};
switch(desc.proptype) {
case "url":
var urlForm = document.createElement('form');
formSubmitterDescriptors[propName] = {
prop: {
set: function(value){
$.attr(this, attrName, value);
},
get: function(){
var value = $.attr(this, attrName);
if(value == null){return '';}
urlForm.setAttribute('action', value);
return urlForm.action;
}
}
};
break;
case "boolean":
formSubmitterDescriptors[propName] = {
prop: {
set: function(val){
val = !!val;
if(val){
$.attr(this, 'formnovalidate', 'formnovalidate');
} else {
$(this).removeAttr('formnovalidate');
}
},
get: function(){
return $.attr(this, 'formnovalidate') != null;
}
}
};
break;
case "enum":
formSubmitterDescriptors[propName] = {
prop: {
set: function(value){
$.attr(this, attrName, value);
},
get: function(){
var value = $.attr(this, attrName);
return (!value || ( (value = value.toLowerCase()) && !desc.limitedTo[value] )) ? desc.defaultProp : value;
}
}
};
break;
default:
formSubmitterDescriptors[propName] = {
prop: {
set: function(value){
$.attr(this, attrName, value);
},
get: function(){
var value = $.attr(this, attrName);
return (value != null) ? value : "";
}
}
};
}
if(!formSubmitterDescriptors[attrName]){
formSubmitterDescriptors[attrName] = {};
}
formSubmitterDescriptors[attrName].attr = {
set: function(value){
formSubmitterDescriptors[attrName].attr._supset.call(this, value);
$(this).off(eventName).on(eventName, changeSubmitter);
},
get: function(){
return formSubmitterDescriptors[attrName].attr._supget.call(this);
}
};
formSubmitterDescriptors[attrName].initAttr = true;
formSubmitterDescriptors[attrName].removeAttr = {
value: function(){
$(this).off(eventName);
formSubmitterDescriptors[attrName].removeAttr._supvalue.call(this);
}
};
});
webshims.defineNodeNamesProperties(['input', 'button'], formSubmitterDescriptors);
}); //webshims.ready end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,527 @@
webshims.register('form-validators', function($, webshims, window, document, undefined, options){
"use strict";
var iValClasses = '.'+ options.iVal.errorClass +', .'+options.iVal.successClass;
(function(){
if(webshims.refreshCustomValidityRules){
webshims.error("form-validators already included. please remove custom-validity.js");
}
var customValidityRules = {};
var formReady = false;
var blockCustom;
var initTest;
var elemSels = 'input, select, textarea, fieldset[data-dependent-validation]';
var onEventTest = function(e){
if(e.type == 'refreshCustomValidityRules'){
webshims.error('refreshCustomValidityRules event was renamed to updatecustomvalidity');
}
webshims.refreshCustomValidityRules(e.target);
};
var autocompleteEvaluator = (function(){
function createEvaluator(form){
var noTest;
var elements = {};
var timer;
var reTest = function(){
var elem, val;
for(var id in elements){
elem = elements[id].elem;
if(elem != noTest && elements[id].val != (val = elem.value)){
elements[id].val = val;
if($(elem).hasClass(iValClasses)){
$(elem).trigger('updatevalidation.webshims');
} else {
testValidityRules(elem);
}
}
}
};
$(form).on('autocomplete change', function(e){
clearTimeout(timer);
noTest = e.target;
timer = setTimeout(reTest, 9);
});
return elements;
}
function addToForm(form, elem, id){
var autoCompleteElements = $.data(form, 'autocompleteElements') || $.data(form, 'autocompleteElements', createEvaluator(form));
autoCompleteElements[id] = {
elem: elem,
val: elem.value
};
}
function removeFromForm(form, id){
var autoCompleteElements = $.data(form, 'autocompleteElements');
if(autoCompleteElements && autoCompleteElements[id]){
delete autoCompleteElements[id];
}
}
return {
add: function(elem){
var id, autocomplete;
if((id = elem.id) && (elem.type == 'password' || ((autocomplete = elem.autocomplete) && autocomplete != 'off'))){
setTimeout(function(){
var form = $.prop(elem, 'form');
if(form){
addToForm(form, elem, id);
}
}, 9);
}
},
remove: function(elem){
var id;
if((id = elem.id)){
setTimeout(function(){
var form = $.prop(elem, 'form');
if(form){
removeFromForm(form, id);
}
}, 9);
}
}
};
})();
var noValidate = function(){
return !noValidate.types[this.type];
};
noValidate.types = {
hidden: 1,
image: 1,
button: 1,
reset: 1,
submit: 1
};
webshims.customErrorMessages = {};
webshims.addCustomValidityRule = (function(){
var timer;
var reTest = function(){
$(document.querySelectorAll(elemSels))
.filter(noValidate)
.each(function(){
testValidityRules(this);
})
;
};
return function(name, test, defaultMessage){
customValidityRules[name] = test;
if(!webshims.customErrorMessages[name]){
webshims.customErrorMessages[name] = [];
webshims.customErrorMessages[name][''] = defaultMessage || name;
}
if(formReady){
clearTimeout(timer);
timer = setTimeout(reTest);
}
};
})();
webshims.refreshCustomValidityRules = function(elem){
if(!initTest){return;}
var val, setMessage;
var data = $(elem).data();
var message = '';
var customMismatchedRule = data && data.customMismatchedRule;
var validity = data && $.prop(elem, 'validity') || {valid: 1};
if(data && (customMismatchedRule || validity.valid)){
val = $(elem).val();
setMessage = function(message, errorType){
blockCustom = true;
if(message){
data.customMismatchedRule = errorType;
if(typeof message != 'string'){
message = webshims.getContentValidationMessage(elem, false, errorType);
if(message && typeof message == 'object'){
message = message[errorType];
}
if(!message || typeof message != 'string'){
message = webshims.customErrorMessages[errorType][webshims.activeLang()] || webshims.customErrorMessages[errorType][''] || message.customError || message.defaultMessage || '';
}
}
if(webshims.replaceValidationplaceholder){
message = webshims.replaceValidationplaceholder(elem, message, errorType);
}
autocompleteEvaluator.add(elem);
} else {
message = '';
data.customMismatchedRule = '';
autocompleteEvaluator.remove(elem);
}
$(elem).setCustomValidity(message);
blockCustom = false;
};
$.each(customValidityRules, function(name, test){
message = test(elem, val, data, setMessage) || '';
customMismatchedRule = name;
if(message){
return false;
}
});
if(data && data.dependentValidation && !data.dependentValidation._init && !data.dependentValidation.masterElement){
customValidityRules.dependent(elem, val, data, $.noop);
}
if(message != 'async' && (message || !validity.valid)){
setMessage(message, customMismatchedRule);
}
}
return message;
};
var testValidityRules = webshims.refreshCustomValidityRules;
$('body').on('click', function(e){
if(e.target.type == 'submit' && !e.isDefaultPrevented()){
var activeElement, i, len;
var elements = $(e.target).jProp('form').prop('elements') || [];
try {
activeElement = document.activeElement;
} catch(e){}
for(i = 0, len = elements.length; i < len; i++){
if($.data(elements[i], 'customMismatchedRule')){
if(activeElement == elements[i]){
$(elements[i]).trigger('updatevalidation.webshims');
} else {
testValidityRules(elements[i]);
}
}
}
}
});
webshims.ready('forms form-validation', function(){
$.propHooks.setCustomValidity = {
get: function(elem){
if(!blockCustom){
$.data(elem, 'customMismatchedRule', '');
}
return null;
}
};
setTimeout(function(){
webshims.addReady(function(context, selfElement){
initTest = true;
$(context.querySelectorAll(elemSels)).add(selfElement.filter(elemSels))
.filter(noValidate)
.each(function(){
testValidityRules(this);
})
;
formReady = true;
});
$(document).on('refreshCustomValidityRules updatecustomvalidity', onEventTest);
}, 29);
});
})();
/*
* adds support for HTML5 constraint validation
* - partial pattern: <input data-partial-pattern="RegExp" />
* - creditcard-validation: <input data-luhn="" />
* - several dependent-validation patterns (examples):
* - <input type="email" id="mail" /> <input data-dependent-validation='mail' />
* - <input type="date" id="start" data-dependent-validation='{"from": "end", "prop": "max"}' /> <input type="date" id="end" data-dependent-validation='{"from": "start", "prop": "min"}' />
* - <input type="checkbox" id="check" /> <input data-dependent-validation='checkbox' />
*/
(function(){
var formCFG = webshims.cfg.forms;
var addCustomValidityRule = webshims.addCustomValidityRule;
var getId = function(name){
return document.getElementById(name) || document.getElementsByName(name);
};
addCustomValidityRule('partialPattern', function(elem, val, pattern){
pattern = pattern.partialPattern;
if(!val || !pattern){return;}
return !(new RegExp('(' + pattern + ')', 'i').test(val));
}, 'This format is not allowed here.');
if(!('tooShort' in ($('<input />').prop('validity') || {}))){
addCustomValidityRule('tooShort', function(elem, val){
var minlength;
if(!val || val == elem.defaultValue || !(minlength = elem.getAttribute('minlength'))){return;}
minlength = parseInt(minlength, 10);
return minlength > 0 && minlength > val.length ? (webshims.validityMessages.__active || {}).tooShort || true : '';
}, 'Entered value is too short.');
}
addCustomValidityRule('grouprequired', function(elem, val, data){
var form, name;
if(!('grouprequired' in data) || elem.type !== 'checkbox' || !(name = elem.name)){return;}
if(!data.grouprequired.checkboxes){
data.grouprequired = {};
data.grouprequired.checkboxes = $( ((form = $.prop(elem, 'form')) && form[name]) || document.getElementsByName(name)).filter('[type="checkbox"]');
data.grouprequired.checkboxes
.off('click.groupRequired')
.on('click.groupRequired', function(){
webshims.refreshCustomValidityRules(elem);
})
;
data.grouprequired.checkboxes.not(elem).removeData('grouprequired');
}
return !(data.grouprequired.checkboxes.filter(':checked:enabled')[0]);
}, 'Please check one of these checkboxes.');
// based on https://sites.google.com/site/abapexamples/javascript/luhn-validation
addCustomValidityRule('luhn', function(elem, value, data){
if(!value || (!data || (!('creditcard' in data) && !('luhn' in data)))){return;}
if(('creditcard' in data)){
webshims.error('data-creditcard was renamed to data-luhn!!!');
}
value = value.replace(/\-/g, "");
//if it's not numeric return true >- for invalid
if(value != value * 1){return true;}
var len = value.length;
var sum = 0;
var mul = 1;
var ca;
while (len--) {
ca = parseInt(value.charAt(len),10) * mul;
sum += ca - (ca>9)*9;// sum += ca - (-(ca>9))|9
// 1 <--> 2 toggle.
mul ^= 3; // (mul = 3 - mul);
}
return !((sum%10 === 0) && (sum > 0));
}, 'Please enter a valid credit card number');
var dependentDefaults = {
//"from": "IDREF || UniqueNAMEREF", //required property: element
"prop": "value", //default: value||disabled (last if "from-prop" is checked)
"from-prop": "value", //default: value||checked (last if element checkbox or radio)
"toggle": false
};
var getGroupElements = function(elem) {
return $(elem.form[elem.name]).filter('[type="radio"]');
};
webshims.ready('form-validation', function(){
if(webshims.modules){
getGroupElements = webshims.modules["form-core"].getGroupElements || getGroupElements;
}
});
addCustomValidityRule('dependent', function(elem, val, data){
data = data.dependentValidation;
if( !data ){return;}
var specialVal;
var depFn = function(e){
var val = $.prop(data.masterElement, data["from-prop"]);
if(specialVal){
val = $.inArray(val, specialVal) !== -1;
}
if(data.toggle){
val = !val;
}
$.prop( elem, data.prop, val);
if(e){
$(elem).getShadowElement().filter(iValClasses).trigger('updatevalidation.webshims');
}
};
if(!data._init || !data.masterElement){
if(typeof data == 'string'){
data = {"from": data};
}
data.masterElement = document.getElementById(data["from"]) || (document.getElementsByName(data["from"] || [])[0]);
data._init = true;
if (!data.masterElement || !data.masterElement.form) {return;}
if(/radio|checkbox/i.test(data.masterElement.type)){
if(!data["from-prop"]){
data["from-prop"] = 'checked';
}
if(!data.prop && data["from-prop"] == 'checked'){
data.prop = 'disabled';
}
} else if(!data["from-prop"]){
data["from-prop"] = 'value';
}
if(data["from-prop"].indexOf('value:') === 0){
specialVal = data["from-prop"].replace('value:', '').split('||');
data["from-prop"] = 'value';
}
data = $.data(elem, 'dependentValidation', $.extend({_init: true}, dependentDefaults, data));
if(data.prop !== "value" || specialVal){
$(data.masterElement.type === 'radio' && getGroupElements(data.masterElement) || data.masterElement).on('change', depFn);
} else {
$(data.masterElement).on('change', function(){
webshims.refreshCustomValidityRules(elem);
$(elem)
.getShadowElement()
.filter(iValClasses)
.trigger('updatevalidation.webshims')
;
});
}
}
if(data.prop == "value" && !specialVal){
return ($.prop(data.masterElement, 'value') != val);
} else {
depFn();
return '';
}
}, 'The value of this field does not repeat the value of the other field');
addCustomValidityRule('validatevalue', function(elem, val, data){
if(('validatevalue' in data)){
return $(elem).triggerHandler('validatevalue', [{value: val, valueAsDate: $.prop(elem, 'valueAsDate'), isPartial: false}]) || '';
}
}, 'This value is not allowed here');
addCustomValidityRule('ajaxvalidate', function(elem, val, data){
if(!val || !data.ajaxvalidate){return;}
var opts;
if(!data.remoteValidate){
webshims.loader.loadList(['jajax']);
if(typeof data.ajaxvalidate == 'string'){
data.ajaxvalidate = {url: data.ajaxvalidate, depends: $([])};
} else {
data.ajaxvalidate.depends = data.ajaxvalidate.depends ?
$(typeof data.ajaxvalidate.depends == 'string' && data.ajaxvalidate.depends.split(' ') || data.ajaxvalidate.depends).map(getId) :
$([])
;
}
data.ajaxvalidate.depends.on('change', function(){
if($(this).is(':valid')){
webshims.refreshCustomValidityRules(elem);
}
});
opts = data.ajaxvalidate;
var remoteValidate = {
ajaxLoading: false,
restartAjax: false,
message: 'async',
cache: {},
update: function(remoteData){
if(this.ajaxLoading){
this.restartAjax = remoteData;
} else {
this.restartAjax = false;
this.ajaxLoading = true;
$.ajax(
$.extend({dataType: 'json'}, opts, {
url: opts.url,
depData: remoteData,
data: formCFG.fullRemoteForm || opts.fullForm ?
$(elem).jProp('form').serializeArray() :
remoteData,
success: this.getResponse,
complete: this._complete,
timeout: 3000
})
);
}
},
_complete: function(){
remoteValidate.ajaxLoading = false;
if(remoteValidate.restartAjax){
this.update(remoteValidate.restartAjax);
}
remoteValidate.restartAjax = false;
},
getResponse: function(data){
if(options.transformAjaxValidate){
data = options.transformAjaxValidate(data);
}
if(!data){
data = {message: '', valid: true};
} else if(typeof data == 'string'){
try {
data = JSON.parse(data);
} catch (er){}
}
remoteValidate.message = ('message' in data) ? data.message : !data.valid;
remoteValidate.lastMessage = remoteValidate.message;
remoteValidate.blockUpdate = true;
$(elem).triggerHandler('updatevalidation.webshims');
remoteValidate.message = 'async';
remoteValidate.blockUpdate = false;
},
getData: function(){
var data;
data = {};
data[$.prop(elem, 'name') || $.prop(elem, 'id')] = $(elem).val();
opts.depends.each(function(){
if($(this).is(':invalid')){
data = false;
return false;
}
data[$.prop(this, 'name') || $.prop(this, 'id')] = $(this).val();
});
return data;
},
getTempMessage: function(){
var message = 'async';
var remoteData, dataStr;
if(!data.remoteValidate.blockUpdate){
remoteData = this.getData();
if(!remoteData){
message = '';
} else {
try {
dataStr = JSON.stringify(remoteData);
} catch(er){}
if(dataStr === this.lastString){
message = this.ajaxLoading ? 'async' : this.lastMessage;
} else {
this.lastString = dataStr;
this.lastMessage = 'async';
clearTimeout(data.remoteValidate.timer);
data.remoteValidate.timer = setTimeout(function(){
data.remoteValidate.update(remoteData);
}, 9);
}
}
} else {
message = remoteValidate.message;
}
return message;
}
};
data.remoteValidate = remoteValidate;
}
return data.remoteValidate.getTempMessage();
}, 'remote error');
})();
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,187 @@
(function($){
var webshims = window.webshims;
setTimeout(function(){
webshims.isReady('geolocation', true);
});
var domWrite = function(){
setTimeout(function(){
throw('document.write is overwritten by geolocation shim. This method is incompatible with this plugin');
}, 1);
},
id = 0
;
var geoOpts = webshims.cfg.geolocation || {};
if(!navigator.geolocation){
navigator.geolocation = {};
}
$.extend(navigator.geolocation, (function(){
var pos;
var api = {
getCurrentPosition: function(success, error, opts){
var locationAPIs = 2,
errorTimer,
googleTimer,
calledEnd,
createAjax,
endCallback = function(){
if(calledEnd){return;}
if(pos){
calledEnd = true;
success($.extend({timestamp: new Date().getTime()}, pos));
resetCallback();
if(window.JSON && window.sessionStorage){
try{
sessionStorage.setItem('storedGeolocationData654321', JSON.stringify(pos));
} catch(e){}
}
} else if(error && !locationAPIs) {
calledEnd = true;
resetCallback();
error({ code: 2, message: "POSITION_UNAVAILABLE"});
}
},
googleCallback = function(){
locationAPIs--;
getGoogleCoords();
endCallback();
},
resetCallback = function(){
$(document).off('google-loader', resetCallback);
clearTimeout(googleTimer);
clearTimeout(errorTimer);
},
getGoogleCoords = function(){
if(pos || !window.google || !google.loader || !google.loader.ClientLocation){return false;}
var cl = google.loader.ClientLocation;
pos = {
coords: {
latitude: cl.latitude,
longitude: cl.longitude,
altitude: null,
accuracy: 43000,
altitudeAccuracy: null,
heading: parseInt('NaN', 10),
velocity: null
},
//extension similiar to FF implementation
address: $.extend({streetNumber: '', street: '', premises: '', county: '', postalCode: ''}, cl.address)
};
return true;
},
getInitCoords = function(){
if(pos){return;}
getGoogleCoords();
if(pos || !window.JSON || !window.sessionStorage){return;}
try{
pos = sessionStorage.getItem('storedGeolocationData654321');
pos = (pos) ? JSON.parse(pos) : false;
if(!pos.coords){pos = false;}
} catch(e){
pos = false;
}
}
;
getInitCoords();
if(!pos){
if(geoOpts.confirmText && !confirm(geoOpts.confirmText.replace('{location}', location.hostname))){
if(error){
error({ code: 1, message: "PERMISSION_DENIED"});
}
return;
}
createAjax = function(){
$.ajax({
url: 'http://freegeoip.net/json/',
dataType: 'jsonp',
cache: true,
jsonp: 'callback',
success: function(data){
locationAPIs--;
if(!data){return;}
pos = pos || {
coords: {
latitude: data.latitude,
longitude: data.longitude,
altitude: null,
accuracy: 43000,
altitudeAccuracy: null,
heading: parseInt('NaN', 10),
velocity: null
},
//extension similiar to FF implementation
address: {
city: data.city,
country: data.country_name,
countryCode: data.country_code,
county: "",
postalCode: data.zipcode,
premises: "",
region: data.region_name,
street: "",
streetNumber: ""
}
};
endCallback();
},
error: function(){
locationAPIs--;
endCallback();
}
});
};
if($.ajax){
createAjax();
} else {
webshims.ready('jajax', createAjax);
webshims.loader.loadList(['jajax']);
}
clearTimeout(googleTimer);
if (!window.google || !window.google.loader) {
googleTimer = setTimeout(function(){
//destroys document.write!!!
if (geoOpts.destroyWrite) {
document.write = domWrite;
document.writeln = domWrite;
}
$(document).one('google-loader', googleCallback);
webshims.loader.loadScript('http://www.google.com/jsapi', false, 'google-loader');
}, 800);
} else {
locationAPIs--;
}
} else {
setTimeout(endCallback, 1);
return;
}
if(opts && opts.timeout){
errorTimer = setTimeout(function(){
resetCallback();
if(error) {
error({ code: 3, message: "TIMEOUT"});
}
}, opts.timeout);
} else {
errorTimer = setTimeout(function(){
locationAPIs = 0;
endCallback();
}, 10000);
}
},
clearWatch: $.noop
};
api.watchPosition = function(a, b, c){
api.getCurrentPosition(a, b, c);
id++;
return id;
};
return api;
})());
webshims.ready('WINDOWLOAD', function(){
webshims.loader.loadList(['jajax']);
});
webshims.isReady('geolocation', true);
})(webshims.$);

View File

@ -0,0 +1,64 @@
webshims.validityMessages.ar = {
"typeMismatch": {
"email": "أدخِل رجاءً البريد الإلكتروني.",
"url": "أدخِل رجاءً عنوان الموقع."
},
"badInput": {
"number": "قيمة غير صحيحة",
"date": "قيمة غير صحيحة",
"time": "قيمة غير صحيحة",
"range": "قيمة غير صحيحة",
"datetime-local": "قيمة غير صحيحة"
},
"tooLong": "قيمة غير صحيحة",
"patternMismatch": "اتبع رجاءً التنسيق المطلوب: {%title}.",
"valueMissing": {
"defaultMessage": "رجاءً املأ هذا الحقل.",
"checkbox": "رجاءً علّم هذا المربع إن أردت المتابعة.",
"select": "رجاءً اختر عنصرًا من اللائحة.",
"radio": "رجاءً اختر أحد هذه الخيارات."
},
"rangeUnderflow": {
"defaultMessage": "يجب أن تكون القيمة أكبر من أو تساوي {%min}.",
"date": "يجب أن تكون القيمة أكبر من أو تساوي {%min}.",
"time": "يجب أن تكون القيمة أكبر من أو تساوي {%min}.",
"datetime-local": "يجب أن تكون القيمة أكبر من أو تساوي {%min}."
},
"rangeOverflow": {
"defaultMessage": "يجب أن تكون القيمة أقل من أو تساوي {%max}.",
"date": "يجب أن تكون القيمة أقل من أو تساوي {%max}.",
"time": "يجب أن تكون القيمة أقل من أو تساوي {%max}.",
"datetime-local": "يجب أن تكون القيمة أقل من أو تساوي {%max}."
},
"stepMismatch": "قيمة غير صحيحة"
};
webshims.formcfg.ar = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: 'dd/mm/yy'
},
date: {
closeText: 'إغلاق',
prevText: '&#x3C;السابق',
nextText: 'التالي&#x3E;',
currentText: 'اليوم',
monthNames: ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'مايو', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
dayNamesMin: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'],
weekHeader: 'أسبوع',
firstDay: 6,
isRTL: true,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages['zh-CN'] = {
"typeMismatch": {
"email": "请输入电子邮件地址。",
"url": "请输入一个 URL。"
},
"badInput": {
"number": "值无效。",
"date": "值无效。",
"time": "值无效。",
"range": "值无效。",
"datetime-local": "值无效。"
},
"tooLong": "值无效。",
"patternMismatch": "请匹配要求的格式: {%title}。",
"valueMissing": {
"defaultMessage": "请填写此字段。",
"checkbox": "若要继续,请检选此检查框。",
"select": "请选择列表中的一项。",
"radio": "请选择一个选项。"
},
"rangeUnderflow": {
"defaultMessage": "值无效。",
"date": "值无效。",
"time": "值无效。",
"datetime-local": "值无效。"
},
"rangeOverflow": {
"defaultMessage": "值无效。",
"date": "值无效。",
"time": "值无效。",
"datetime-local": "值无效。"
},
"stepMismatch": "值无效。"
};
webshims.formcfg['zh-CN'] = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '-',
timeSigns: ":. ",
dFormat: "-",
patterns: {
d: "yy-mm-dd"
},
date: {
closeText: '关闭',
prevText: '&#x3C;上月',
nextText: '下月&#x3E;',
currentText: '今天',
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
weekHeader: '周',
firstDay: 1,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: '年'
}
};

View File

@ -0,0 +1,112 @@
webshims.validityMessages.cs = {
"typeMismatch": {
"defaultMessage": "Prosím vložte platnou hodnotu.",
"email": "Prosím vložte emailovou adresu.",
"url": "Prosím vložte URL."
},
"badInput": {
"defaultMessage": "Prosím vložte platnou hodnotu.",
"number": "Prosím vložte číslo.",
"date": "Prosím vložte datum.",
"time": "Prosím vložte čas.",
"range": "Neplatná vstupní hodnota.",
"month": "Prosím vložte platnou hodnotu.",
"datetime-local": "Prosím vložte datum a čas."
},
"rangeUnderflow": {
"defaultMessage": "Hodnota musí být větší nebo rovna {%min}.",
"date": "Datum musí být od {%min}.",
"time": "Čas musí být od {%min}.",
"datetime-local": "Datum a čas musí být od {%min}.",
"month": "Měsíc musí být od {%min}.",
},
"rangeOverflow": {
"defaultMessage": "Hodnota musí být větší nebo rovna {%mas}.",
"date": "Datum musí být od {%mas}.",
"time": "Čas musí být od {%mas}.",
"datetime-local": "Datum a čas musí být od {%mas}.",
"month": "Měsíc musí být od {%mas}.",
},
"stepMismatch": "Neplatná vstupní hodnota.",
"tooLong": "Maximálně můžete vložit {%maxlength} znaků. Zadali jste {%valueLen}.",
"patternMismatch": "Neplatná vstupní hodnota. {%title}",
"valueMissing": {
"defaultMessage": "Prosím vyplňte toto pole",
"checkbox": "Prosím zaškrtněte toto políčko, pokud chcete pokračovat.",
"select": "Prosím zvolte možnost.",
"radio": "Prosím zvolte možnost."
}
};
webshims.formcfg.cs = {
"numberFormat": {
".": ",",
",": " "
},
"numberSigns": ".-",
"dateSigns": ".",
"timeSigns": ":. ",
"dFormat": ".",
"patterns": {
"d": "dd.mm.yy"
},
"month": {
"currentText": "Tento měsíc"
},
"week": {
"currentText": "Tento týden"
},
"time": {
"currentText": "Nyní"
},
"date": {
"closeText": "Hotovo",
"clear": "Smazat",
"prevText": "Předchozí",
"nextText": "Další",
"currentText": "Dnešek",
"monthNames": [
"Leden",
"Únor",
"Březen",
"Duben",
"Květen",
"Červen",
"Červenec",
"Srpen",
"Září",
"Říjen",
"Listopad",
"Prosinec"
],
"monthNamesShort": [
"Led",//??
"Ún",
"Bře",
"Dub",
"Kvě",
"Čer",
"Čec",
"Srp",
"Zář",
"Říj",
"Lis",
"Pro"
],
"dayNames": [
"Neděle",
"Pondělí",
"Úterý",
"Středa",
"Čtvrtek",
"Pátek",
"Sobota"
],
"dayNamesShort": ["NE", "PO", "ÚT", "ST", "ČT", "PÁ", "SO"],
"dayNamesMin": ["NE", "PO", "ÚT", "ST", "ČT", "PÁ", "SO"],
"weekHeader": "Týden",
"firstDay": 1,
"isRTL": false,
"showMonthAfterYear": false,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,127 @@
webshims.validityMessages.de = {
"typeMismatch": {
"defaultMessage": "{%value} ist in diesem Feld nicht zulässig.",
"email": "{%value} ist keine gültige E-Mail-Adresse.",
"url": "{%value} ist kein(e) gültige(r) Webadresse/Pfad."
},
"badInput": {
"defaultMessage": "Geben Sie einen zulässigen Wert ein.",
"number": "Geben Sie eine Nummer ein.",
"date": "Geben Sie ein Datum ein.",
"time": "Geben Sie eine Uhrzeit ein.",
"month": "Geben Sie einen Monat mit Jahr ein.",
"range": "Geben Sie eine Nummer.",
"datetime-local": "Geben Sie ein Datum mit Uhrzeit ein."
},
"rangeUnderflow": {
"defaultMessage": "{%value} ist zu niedrig. {%min} ist der unterste Wert, den Sie benutzen können.",
"date": "{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.",
"time": "{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.",
"datetime-local": "{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.",
"month": "{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können."
},
"rangeOverflow": {
"defaultMessage": "{%value} ist zu hoch. {%max} ist der oberste Wert, den Sie benutzen können.",
"date": "{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.",
"time": "{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.",
"datetime-local": "{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.",
"month": "{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können."
},
"stepMismatch": "Der Wert {%value} ist in diesem Feld nicht zulässig. Hier sind nur bestimmte Werte zulässig. {%title}",
"tooLong": "Der eingegebene Text ist zu lang! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%maxlength} das Maximum.",
"tooShort": "Der eingegebene Text ist zu kurz! Sie haben {%valueLen} Zeichen eingegeben, dabei sind {%minlength} das Minimum.",
"patternMismatch": "{%value} hat für dieses Eingabefeld ein falsches Format. {%title}",
"valueMissing": {
"defaultMessage": "Bitte geben Sie einen Wert ein.",
"checkbox": "Bitte aktivieren Sie das Kästchen.",
"select": "Bitte wählen Sie eine Option aus.",
"radio": "Bitte wählen Sie eine Option aus."
}
};
webshims.formcfg.de = {
"numberFormat": {
",": ".",
".": ","
},
"timeSigns": ":. ",
"numberSigns": ",",
"dateSigns": ".",
"dFormat": ".",
"patterns": {
"d": "dd.mm.yy"
},
"month": {
"currentText": "Aktueller Monat"
},
"time": {
"currentText": "Jetzt"
},
"date": {
"close": "schließen",
"clear": "Löschen",
"prevText": "Zurück",
"nextText": "Vor",
"currentText": "Heute",
"monthNames": [
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"
],
"monthNamesShort": [
"Jan",
"Feb",
"Mär",
"Apr",
"Mai",
"Jun",
"Jul",
"Aug",
"Sep",
"Okt",
"Nov",
"Dez"
],
"dayNames": [
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag"
],
"dayNamesShort": [
"So",
"Mo",
"Di",
"Mi",
"Do",
"Fr",
"Sa"
],
"dayNamesMin": [
"So",
"Mo",
"Di",
"Mi",
"Do",
"Fr",
"Sa"
],
"weekHeader": "KW",
"firstDay": 1,
"isRTL": false,
"showMonthAfterYear": false,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.el = {
"typeMismatch": {
"email": "Παρακαλώ εισάγετε μια διεύθυνση email.",
"url": "Παρακαλώ εισάγετε ένα URL."
},
"badInput": {
"number": "Μη έγκυρη τιμή.",
"date": "Μη έγκυρη τιμή.",
"time": "Μη έγκυρη τιμή.",
"range": "Μη έγκυρη τιμή.",
"datetime-local": "Μη έγκυρη τιμή."
},
"tooLong": "Μη έγκυρη τιμή.",
"patternMismatch": "Αντιστοιχίστε τη ζητούμενη μορφή. {%title}.",
"valueMissing": {
"defaultMessage": "Παρακαλώ συμπληρώστε αυτό το πεδίο.",
"checkbox": "Παρακαλώ επιλέξτε αυτό το κουτί αν θέλετε να συνεχίσετε.",
"select": "Παρακαλώ επιλέξτε ένα αντικείμενο στη λίστα.",
"radio": "Επιλέξτε ένα από τα παρακάτω."
},
"rangeUnderflow": {
"defaultMessage": "Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του {%min}.",
"date": "Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του {%min}.",
"time": "Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του {%min}.",
"datetime-local": "Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του {%min}."
},
"rangeOverflow": {
"defaultMessage": "Η τιμή πρέπει να είναι μικρότερη ή ίση του {%max}.",
"date": "Η τιμή πρέπει να είναι μικρότερη ή ίση του {%max}.",
"time": "Η τιμή πρέπει να είναι μικρότερη ή ίση του {%max}.",
"datetime-local": "Η τιμή πρέπει να είναι μικρότερη ή ίση του {%max}."
},
"stepMismatch": "Μη έγκυρη τιμή."
};
webshims.formcfg.el = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
date: {
closeText: 'Κλείσιμο',
prevText: 'Προηγούμενος',
nextText: 'Επόμενος',
currentText: 'Τρέχων Μήνας',
monthNames: ['Ιανουάριος','Φεβρουάριος','Μάρτιος','Απρίλιος','Μάιος','Ιούνιος',
'Ιούλιος','Αύγουστος','Σεπτέμβριος','Οκτώβριος','Νοέμβριος','Δεκέμβριος'],
monthNamesShort: ['Ιαν','Φεβ','Μαρ','Απρ','Μαι','Ιουν',
'Ιουλ','Αυγ','Σεπ','Οκτ','Νοε','Δεκ'],
dayNames: ['Κυριακή','Δευτέρα','Τρίτη','Τετάρτη','Πέμπτη','Παρασκευή','Σάββατο'],
dayNamesShort: ['Κυρ','Δευ','Τρι','Τετ','Πεμ','Παρ','Σαβ'],
dayNamesMin: ['Κυ','Δε','Τρ','Τε','Πε','Πα','Σα'],
weekHeader: 'Εβδ',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,130 @@
webshims.validityMessages.en = {
"typeMismatch": {
"defaultMessage": "Please enter a valid value.",
"email": "Please enter an email address.",
"url": "Please enter a URL."
},
"badInput": {
"defaultMessage": "Please enter a valid value.",
"number": "Please enter a number.",
"date": "Please enter a date.",
"time": "Please enter a time.",
"range": "Invalid input.",
"month": "Please enter a valid value.",
"datetime-local": "Please enter a datetime."
},
"rangeUnderflow": {
"defaultMessage": "Value must be greater than or equal to {%min}.",
"date": "Value must be at or after {%min}.",
"time": "Value must be at or after {%min}.",
"datetime-local": "Value must be at or after {%min}.",
"month": "Value must be at or after {%min}."
},
"rangeOverflow": {
"defaultMessage": "Value must be less than or equal to {%max}.",
"date": "Value must be at or before {%max}.",
"time": "Value must be at or before {%max}.",
"datetime-local": "Value must be at or before {%max}.",
"month": "Value must be at or before {%max}."
},
"stepMismatch": "Invalid input.",
"tooLong": "Please enter at most {%maxlength} character(s). You entered {%valueLen}.",
"tooShort": "Please enter at least {%minlength} character(s). You entered {%valueLen}.",
"patternMismatch": "Invalid input. {%title}",
"valueMissing": {
"defaultMessage": "Please fill out this field.",
"checkbox": "Please check this box if you want to proceed.",
"select": "Please select an option.",
"radio": "Please select an option."
}
};
webshims.formcfg.en = {
"numberFormat": {
".": ".",
",": ","
},
"numberSigns": ".",
"dateSigns": "/",
"timeSigns": ":. ",
"dFormat": "/",
"patterns": {
"d": "mm/dd/yy"
},
"meridian": [
"AM",
"PM"
],
"month": {
"currentText": "This month"
},
"time": {
"currentText": "Now"
},
"date": {
"closeText": "Done",
"clear": "Clear",
"prevText": "Prev",
"nextText": "Next",
"currentText": "Today",
"monthNames": [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
"monthNamesShort": [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
"dayNames": [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
"dayNamesShort": [
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
],
"dayNamesMin": [
"Su",
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa"
],
"weekHeader": "Wk",
"firstDay": 0,
"isRTL": false,
"showMonthAfterYear": false,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.es = {
"typeMismatch": {
"email": "Por favor, introduzca una dirección de correo.",
"url": "Por favor, introduzca una URL."
},
"badInput": {
"number": "Valor no válido",
"date": "Valor no válido",
"time": "Valor no válido",
"range": "Valor no válido",
"datetime-local": "Valor no válido"
},
"tooLong": "Valor no válido",
"patternMismatch": "Por favor, ajústese al formato solicitado: {%title}.",
"valueMissing": {
"defaultMessage": "Por favor, rellene este campo.",
"checkbox": "Por favor, marque esta casilla si desea continuar.",
"select": "Por favor, seleccione un elemento de la lista.",
"radio": "Por favor, seleccione una de estas opciones."
},
"rangeUnderflow": {
"defaultMessage": "El valor debe superior o igual a {%min}.",
"date": "El valor debe superior o igual a {%min}.",
"time": "El valor debe superior o igual a {%min}.",
"datetime-local": "El valor debe superior o igual a {%min}."
},
"rangeOverflow": {
"defaultMessage": "El valor debe inferior o igual a {%max}.",
"date": "El valor debe inferior o igual a {%max}.",
"time": "El valor debe inferior o igual a {%max}.",
"datetime-local": "El valor debe inferior o igual a {%max}."
},
"stepMismatch": "Valor no válido"
};
webshims.formcfg.es = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: 'dd/mm/yy'
},
date: {
closeText: 'Cerrar',
prevText: '&#x3C;Ant',
nextText: 'Sig&#x3E;',
currentText: 'Hoy',
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
weekHeader: 'Sm',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,130 @@
webshims.validityMessages.fa = {
"typeMismatch": {
"defaultMessage": "خواهشمندیم یک مقدار معتبر وارد نمایید.",
"email": "خواهشمندیم یک آدرس رایانامه وارد نمایید.",
"url": "خواهشمندیم یک آدرس اینترنتی وارد نمایید."
},
"badInput": {
"defaultMessage": "خواهشمندیم یک مقدار معتبر وارد نمایید.",
"number": "خواهشمندیم یک عدد وارد نمایید.",
"date": "خواهشمندیم یک تاریخ وارد نمایید.",
"time": "خواهشمندیم یک زمان وارد نمایید.",
"range": "ورودی نامعتبر.",
"month": "خواهشمندیم یک مقدار معتبر وارد نمایید.",
"datetime-local": "خواهشمندیم یک تاریخ-زمان وارد نمایید."
},
"rangeUnderflow": {
"defaultMessage": "مقدار وارده می بایست بزرگتر-مساوی {%min} باشد.",
"date": "مقدار وارده می بایست برابر {%min} یا بعد تر از آن باشد.",
"time": "مقدار وارده می بایست برابر {%min} یا بعد تر از آن باشد.",
"datetime-local": "مقدار وارده می بایست برابر {%min} یا بعد تر از آن باشد.",
"month": "مقدار وارده می بایست برابر {%min} یا بعد تر از آن باشد."
},
"rangeOverflow": {
"defaultMessage": "مقدار وارده می بایست کوچکتر-مساوی {%max} باشد.",
"date": "مقدار وارده می بایست برابر {%max} یا قبل تر از آن باشد.",
"time": "مقدار وارده می بایست برابر {%max} یا قبل تر از آن باشد.",
"datetime-local": "مقدار وارده می بایست برابر {%max} یا قبل تر از آن باشد.",
"month": "مقدار وارده می بایست برابر {%max} یا قبل تر از آن باشد."
},
"stepMismatch": "ورودی نامعتبر.",
"tooLong": "خواهشمندیم بیش از {%maxlength} نویسه وارد نکنید. شما {%valueLen} وارد نموده اید.",
"tooShort": "خواهشمندیم کم تر از {%minlength} نویسه وارد نکنید. شما {%valueLen} وارد نموده اید.",
"patternMismatch": "ورودی نامعتبر. {%title}",
"valueMissing": {
"defaultMessage": "خواهشمندیم این ورودی را پر نمایید.",
"checkbox": "خواهشمندیم جهت ادامه فعالیت، این ورودی را علامت گذاری نمایید.",
"select": "خواهشمندیم گزینه ای را انتخاب نمایید.",
"radio": "خواهشمندیم گزینه ای را انتخاب نمایید."
}
};
webshims.formcfg.fa = {
"numberFormat": {
".": ".",
",": ","
},
"numberSigns": ".",
"dateSigns": "/",
"timeSigns": ":. ",
"dFormat": "/",
"patterns": {
"d": "yyyy/mm/dd"
},
"meridian": [
"ب.ظ",
"ق.ظ"
],
"month": {
"currentText": "این ماه"
},
"time": {
"currentText": "حال"
},
"date": {
"closeText": "انجام شد",
"clear": "از نو",
"prevText": "پیش",
"nextText": "پس",
"currentText": "امروز",
"monthNames": [
"ژانویه",
"فوریه",
"مارس",
"آوریل",
"مه",
"ژوئن",
"ژوئیه",
"اوت",
"سپتامبر",
"اکتبر",
"نوابر",
"دسامبر"
],
"monthNamesShort": [
"ژانویه",
"فوریه",
"مارس",
"آوریل",
"مه",
"ژوئن",
"ژوئیه",
"اوت",
"سپتامبر",
"اکتبر",
"نوابر",
"دسامبر"
],
"dayNames": [
"یکشنبه",
"دوشنبه",
"سه شنبه",
"چهار شنبه",
"پنجشنبه",
"آدینه",
"شنبه"
],
"dayNamesShort": [
"ی",
"د",
"س",
"چ",
"پ",
"آ",
"ش"
],
"dayNamesMin": [
"ی",
"د",
"س",
"چ",
"پ",
"آ",
"ش"
],
"weekHeader": "هفته",
"firstDay": 6,
"isRTL": true,
"showMonthAfterYear": false,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,76 @@
webshims.validityMessages.fr = {
"typeMismatch": {
"defaultMessage": "Veuillez saisir une valeur valide.",
"email": "Veuillez saisir une adresse courriel valide.",
"url": "Veuillez saisir une URL."
},
"badInput": {
"defaultMessage": "Veuillez saisir une valeur valide.",
"number": "Veuillez saisir un nombre valide.",
"date": "Veuillez saisir une date valide.",
"month": "Veuillez saisir un mois valide.",
"week": "Veuillez saisir un numéro de semaine valide.",
"time": "Veuillez saisir une heure valide.",
"range": "Veuillez saisir une borne valide.",
"datetime-local": "Veuillez saisir une date valide."
},
"tooLong": "Contenu saisi trop long.",
"patternMismatch": "Veuillez modifier la valeur du champ pour correspondre au format demandé : {%title}.",
"valueMissing": {
"defaultMessage": "Veuillez compléter ce champ.",
"checkbox": "Veuillez cocher cette case si vous désirez poursuivre.",
"select": "Veuillez sélectionner un élément de la liste.",
"radio": "Veuillez sélectionner l'une de ces options."
},
"rangeUnderflow": {
"defaultMessage": "Cette valeur doit être supérieure ou égale à {%min}.",
"date": "Cette valeur doit être supérieure ou égale à {%min}.",
"time": "Cette valeur doit être supérieure ou égale à {%min}.",
"datetime-local": "Cette valeur doit être supérieure ou égale à {%min}."
},
"rangeOverflow": {
"defaultMessage": "Cette valeur doit être inférieure ou égale à {%max}",
"date": "Cette valeur doit être inférieure ou égale à {%max}",
"time": "Cette valeur doit être inférieure ou égale à {%max}",
"datetime-local": "Cette valeur doit être inférieure ou égale à {%max}"
},
"stepMismatch": "Valeur incorrecte"
};
webshims.formcfg.fr = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: 'dd/mm/yy'
},
month: {
currentText: 'Ce mois-ci'
},
week: {
currentText: 'Cette semaine-ci'
},
date: {
closeText: 'Fermer',
clear: 'Effacer',
prevText: 'Précédent',
nextText: 'Suivant',
currentText: 'Aujourd\'hui',
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
dayNamesMin: ['D','L','M','M','J','V','S'],
weekHeader: 'Sem.',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.he = {
"typeMismatch": {
"email": "נא להזין כתובת דוא״ל.",
"url": "נא להזין כתובת."
},
"badInput": {
"number": "ערך לא חוקי.",
"date": "ערך לא חוקי.",
"time": "ערך לא חוקי.",
"range": "ערך לא חוקי.",
"datetime-local": "ערך לא חוקי."
},
"tooLong": "ערך לא חוקי.",
"patternMismatch": "נא להתאים למבנה המבוקש: {%title}.",
"valueMissing": {
"defaultMessage": "אנא מלא את שדה זה.",
"checkbox": "סמן את תיבה זו אם ברצונך להמשיך.",
"select": "נא לבחור פריט מהרשימה.",
"radio": "אנא בחר אחת מאפשרויות אלו."
},
"rangeUnderflow": {
"defaultMessage": "הערך חייב להיות גדול מ-{%min} או שווה לו.",
"date": "הערך חייב להיות גדול מ-{%min} או שווה לו.",
"time": "הערך חייב להיות גדול מ-{%min} או שווה לו.",
"datetime-local": "הערך חייב להיות גדול מ-{%min} או שווה לו."
},
"rangeOverflow": {
"defaultMessage": "הערך חייב להיות קטן מ-{%max} או שווה לו.",
"date": "הערך חייב להיות קטן מ-{%max} או שווה לו.",
"time": "הערך חייב להיות קטן מ-{%max} או שווה לו.",
"datetime-local": "הערך חייב להיות קטן מ-{%max} או שווה לו."
},
"stepMismatch": "ערך לא חוקי."
};
webshims.formcfg.he = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: 'dd/mm/yy'
},
date: {
closeText: 'סגור',
prevText: '&#x3C;הקודם',
nextText: 'הבא&#x3E;',
currentText: 'היום',
monthNames: ['ינואר','פברואר','מרץ','אפריל','מאי','יוני',
'יולי','אוגוסט','ספטמבר','אוקטובר','נובמבר','דצמבר'],
monthNamesShort: ['ינו','פבר','מרץ','אפר','מאי','יוני',
'יולי','אוג','ספט','אוק','נוב','דצמ'],
dayNames: ['ראשון','שני','שלישי','רביעי','חמישי','שישי','שבת'],
dayNamesShort: ['א\'','ב\'','ג\'','ד\'','ה\'','ו\'','שבת'],
dayNamesMin: ['א\'','ב\'','ג\'','ד\'','ה\'','ו\'','שבת'],
weekHeader: 'Wk',
firstDay: 0,
isRTL: true,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.hi = {
"typeMismatch": {
"email": "कृपया ई-मेल पता दर्ज करें.",
"url": "कृपया URL लिखें."
},
"badInput": {
"number": "अमान्य मान.",
"date": "अमान्य मान.",
"time": "अमान्य मान.",
"range": "अमान्य मान.",
"datetime-local": "अमान्य मान."
},
"tooLong": "अमान्य मान.",
"patternMismatch": "कृपया अनुरोधित प्रारूप का मिलान करें. {%title}.",
"valueMissing": {
"defaultMessage": "कृपया इस फ़ील्ड को भरें.",
"checkbox": "यदि आप आगे बढ़ना चाहते हैं तो इस बॉक्‍स को चेक करें.",
"select": "कृपया सूची में किसी आइटम का चयन करें.",
"radio": "कृपया इनमें से कोई विकल्प चुनें."
},
"rangeUnderflow": {
"defaultMessage": "मान {%min} से कम या इसके बराबर होना चाहिए.",
"date": "मान {%min} से कम या इसके बराबर होना चाहिए.",
"time": "मान {%min} से कम या इसके बराबर होना चाहिए.",
"datetime-local": "मान {%min} से कम या इसके बराबर होना चाहिए."
},
"rangeOverflow": {
"defaultMessage": "मान {%max} से कम या इसके बराबर होना चाहिए.",
"date": "मान {%max} से कम या इसके बराबर होना चाहिए.",
"time": "मान {%max} से कम या इसके बराबर होना चाहिए.",
"datetime-local": "मान {%max} से कम या इसके बराबर होना चाहिए."
},
"stepMismatch": "अमान्य मान."
};
webshims.formcfg.hi = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
date: {
closeText: 'बंद',
prevText: 'पिछला',
nextText: 'अगला',
currentText: 'आज',
monthNames: ['जनवरी ','फरवरी','मार्च','अप्रेल','मई','जून',
'जूलाई','अगस्त ','सितम्बर','अक्टूबर','नवम्बर','दिसम्बर'],
monthNamesShort: ['जन', 'फर', 'मार्च', 'अप्रेल', 'मई', 'जून',
'जूलाई', 'अग', 'सित', 'अक्ट', 'नव', 'दि'],
dayNames: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार'],
dayNamesShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
dayNamesMin: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
weekHeader: 'हफ्ता',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.hu = {
"typeMismatch": {
"email": "Írjon be egy e-mail címet.",
"url": "Írjon be egy URL-t."
},
"badInput": {
"number": "Érvénytelen érték.",
"date": "Érvénytelen érték.",
"time": "Érvénytelen érték.",
"range": "Érvénytelen érték.",
"datetime-local": "Érvénytelen érték."
},
"tooLong": "Érvénytelen érték.",
"patternMismatch": "A kért formátumban adja meg az adatot: {%title}.",
"valueMissing": {
"defaultMessage": "Töltse ki ezt a mezőt.",
"checkbox": "Jelölje be ezt a négyzetet a folytatáshoz.",
"select": "Jelöljön ki egy elemet a listából.",
"radio": "Jelöljön ki egyet a lehetőségek közül."
},
"rangeUnderflow": {
"defaultMessage": "Az érték legyen nagyobb vagy egyenlő, mint {%min}.",
"date": "Az érték legyen nagyobb vagy egyenlő, mint {%min}.",
"time": "Az érték legyen nagyobb vagy egyenlő, mint {%min}.",
"datetime-local": "Az érték legyen nagyobb vagy egyenlő, mint {%min}."
},
"rangeOverflow": {
"defaultMessage": "Az érték legyen kisebb vagy egyenlő, mint {%max}.",
"date": "Az érték legyen kisebb vagy egyenlő, mint {%max}.",
"time": "Az érték legyen kisebb vagy egyenlő, mint {%max}.",
"datetime-local": "Az érték legyen kisebb vagy egyenlő, mint {%max}."
},
"stepMismatch": "Érvénytelen érték."
};
webshims.formcfg.hu = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '.',
timeSigns: ":. ",
dFormat: ".",
patterns: {
d: 'yy.mm.dd'
},
date: {
closeText: 'bezár',
prevText: 'vissza',
nextText: 'előre',
currentText: 'ma',
monthNames: ['Január', 'Február', 'Március', 'Április', 'Május', 'Június',
'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún',
'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'],
dayNames: ['Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'],
dayNamesShort: ['Vas', 'Hét', 'Ked', 'Sze', 'Csü', 'Pén', 'Szo'],
dayNamesMin: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
weekHeader: 'Hét',
firstDay: 1,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.it = {
"typeMismatch": {
"email": "Inserire un indirizzo e-mail",
"url": "Inserire un URL"
},
"badInput": {
"number": "Valore non valido.",
"date": "Valore non valido.",
"time": "Valore non valido.",
"range": "Valore non valido.",
"datetime-local": "Valore non valido."
},
"tooLong": "Valore non valido.",
"patternMismatch": "Inserire un valore nel formato richiesto: {%title}",
"valueMissing": {
"defaultMessage": "Compilare questo campo",
"checkbox": "Selezionare questa casella per procedere",
"select": "Selezionare un elemento dall'elenco",
"radio": "Selezionare una delle opzioni disponibili"
},
"rangeUnderflow": {
"defaultMessage": "Il valore deve essere superiore o uguale a {%min}.",
"date": "Il valore deve essere superiore o uguale a {%min}.",
"time": "Il valore deve essere superiore o uguale a {%min}.",
"datetime-local": "Il valore deve essere superiore o uguale a {%min}."
},
"rangeOverflow": {
"defaultMessage": "Il valore deve essere inferiore o uguale a {%max}.",
"date": "Il valore deve essere inferiore o uguale a {%max}.",
"time": "Il valore deve essere inferiore o uguale a {%max}.",
"datetime-local": "Il valore deve essere inferiore o uguale a {%max}."
},
"stepMismatch": "Valore non valido."
};
webshims.formcfg.it = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
date: {
closeText: 'Chiudi',
prevText: '&#x3C;Prec',
nextText: 'Succ&#x3E;',
currentText: 'Oggi',
monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
'Lug','Ago','Set','Ott','Nov','Dic'],
dayNames: ['Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato'],
dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
dayNamesMin: ['Do','Lu','Ma','Me','Gi','Ve','Sa'],
weekHeader: 'Sm',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.ja = {
"typeMismatch": {
"email": "メールアドレスが正しくありません。",
"url": "URL が正しくありません。"
},
"badInput": {
"number": "値が無効です。",
"date": "値が無効です。",
"time": "値が無効です。",
"range": "値が無効です。",
"datetime-local": "値が無効です。"
},
"tooLong": "値が無効です。",
"patternMismatch": "入力された値がフィールドに指定された書式と異なります: {%title}",
"valueMissing": {
"defaultMessage": "このフィールドは入力必須です。",
"checkbox": "チェックボックスにチェックを入れてください。",
"select": "リストから項目を選択してください。",
"radio": "いずれかのオプションを選択してください。"
},
"rangeUnderflow": {
"defaultMessage": "値は {%min} 以上にする必要があります。",
"date": "値は {%min} 以上にする必要があります。",
"time": "値は {%min} 以上にする必要があります。",
"datetime-local": "値は {%min} 以上にする必要があります。"
},
"rangeOverflow": {
"defaultMessage": "値は {%max} 以下にする必要があります。",
"date": "値は {%max} 以下にする必要があります。",
"time": "値は {%max} 以下にする必要があります。",
"datetime-local": "値は {%max} 以下にする必要があります。"
},
"stepMismatch": "値が無効です。"
};
webshims.formcfg.ja = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "yy/mm/dd"
},
date: {
closeText: '閉じる',
prevText: '&#x3C;前',
nextText: '次&#x3E;',
currentText: '今日',
monthNames: ['1月','2月','3月','4月','5月','6月',
'7月','8月','9月','10月','11月','12月'],
monthNamesShort: ['1月','2月','3月','4月','5月','6月',
'7月','8月','9月','10月','11月','12月'],
dayNames: ['日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'],
dayNamesShort: ['日','月','火','水','木','金','土'],
dayNamesMin: ['日','月','火','水','木','金','土'],
weekHeader: '週',
firstDay: 0,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: '年'
}
};

View File

@ -0,0 +1,78 @@
webshims.validityMessages.lt = {
"typeMismatch": {
"defaultMessage": "Prašom įvesti teisingą reikšmę.",
"email": "Prašom įvesti el. pašto adresą.",
"url": "Prašom įvesti nuorodą (URL)."
},
"badInput": {
"defaultMessage": "Prašom įvesti teisingą reikšmę.",
"number": "Prašom įvesti skaičių.",
"date": "Prašom įvesti datą.",
"time": "Prašom įvesti laiką.",
"range": "Neteisingas skaičių rėžis.",
"month": "Prašom įvesti mėnesį.",
"datetime-local": "Prašom įvesti datą ir laiką."
},
"rangeUnderflow": {
"defaultMessage": "Reikšmė privalo būti didesnė arba lygi {%min}.",
"date": "Data turi būti ne ankstesnė negu {%min}.",
"time": "Laikas turi būti ne ankstesnis negu {%min}.",
"datetime-local": "Data ir laikas turi būti ne ankstesni negu {%min}.",
"month": "Mėnuo turi būti {%min} arba vėlesnis."
},
"rangeOverflow": {
"defaultMessage": "Reikšmė privalo būti mažesnė arba lygi {%max}.",
"date": "Data turi būti ne vėlesnė negu {%max}.",
"time": "Laikas turi būti ne vėlesnis negu {%max}.",
"datetime-local": "Data ir laikas turi būti ne vėlesni negu {%max}.",
"month": "Mėnuo turi būti {%max} arba ankstesnis."
},
"stepMismatch": "Neteisinga reikšmė.",
"tooLong": "Prašom įvesti ne daugiau negu {%maxlength} simbolių. Jūs įvedėte {%valueLen}.",
"patternMismatch": "Neteisinga lauko {%title} reikšmė.",
"valueMissing": {
"defaultMessage": "Šis laukas yra privalomas.",
"checkbox": "Prašome pažymėti šį žymimąjį laukelį, jis yra privalomas.",
"select": "Prašom pasirinkti reikšmę iš sąrašo.",
"radio": "Prašom pasirinkti vieną iš reikšmių."
}
};
webshims.formcfg.lt = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '.',
timeSigns: ":. ",
dFormat: ".",
patterns: {
d: "yy.mm.dd"
},
"month": {
"currentText": "šį mėnesį"
},
date: {
"closeText": "Uždaryti",
"clear": "Tuštinti",
"prevText": "Atgal",
"nextText": "Kitas",
"currentText": "Šiandien",
"monthNames": ["Sausis","Vasaris","Kovas","Balandis","Gegužė","Birželis","Liepa","Rugpjūtis","Rugsėjis","Spalis","Lapkritis","Gruodis"],
"monthNamesShort": ["Sau","Vas","Kov","Bal","Geg","Bir","Lie","Rugp","Rugs","Spa","Lap","Gruo"],
"dayNames": ["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis"],
"dayNamesShort": ["Sek","Pir","Ant","Tre","Ket","Pen","Šeš"],
"dayNamesMin": ["S","P","A","T","K","Pn","Š"],
"weekHeader": "Sav.",
"firstDay": 1,
"isRTL": false,
"showMonthAfterYear": true,
"yearSuffix": ""
}
};
//for IE
webshims.validityMessages['lt-LT'] = webshims.validityMessages.lt;
webshims.formcfg['lt-LT'] = webshims.formcfg.lt;

View File

@ -0,0 +1,126 @@
webshims.validityMessages.nl = {
"typeMismatch": {
"defaultMessage": "Voer een geldige waarde in.",
"email": "Voer een geldig e-mailadres in.",
"url": "Voer een geldige website url in."
},
"badInput": {
"defaultMessage": "Voer een geldige waarde in.",
"number": "Voer een nummer in.",
"date": "Voer een datum in.",
"time": "Voer een tijd in.",
"range": "Voer een bereik in.",
"month": "Voer een maand in.",
"datetime-local": "Voer een lokale datumtijd in."
},
"rangeUnderflow": {
"defaultMessage": "Waarde moet groter dan of gelijk zijn aan {%min}.",
"date": "Datum moet op of na {%min} zijn.",
"time": "Tijd moet op of na {%min} zijn.",
"datetime-local": "Datumtijd moet op of na {%min} zijn.",
"month": "Maand moet op of na {%min} zijn."
},
"rangeOverflow": {
"defaultMessage": "Waarde moet kleiner dan of gelijk zijn aan {%max}.",
"date": "Datum moet op of voor {%max} zijn.",
"time": "Tijd moet op of voor {%max} zijn.",
"datetime-local": "Waarde moet kleiner dan of gelijk zijn aan {%max}.",
"month": "Maand moet op of voor {%max} zijn."
},
"stepMismatch": "Ongeldige invoer.",
"tooLong": "Voer maximaal {%maxLength} karakter(s) in. {%valueLen} is te lang.",
"tooShort": "Voer minimaal {%minLength} karakter(s) in. {%valueLen} is te kort.",
"patternMismatch": "Voer een waarde in met de gevraagde opmaak: {%title}.",
"valueMissing": {
"defaultMessage": "Vul dit veld in.",
"checkbox": "Vink dit vakje aan als u wilt doorgaan.",
"select": "Selecteer een item in de lijst.",
"radio": "Selecteer één van deze opties."
}
};
webshims.formcfg.nl = {
"numberFormat": {
",": ".",
".": ","
},
"numberSigns": ",",
"dateSigns": "-",
"timeSigns": ":. ",
"dFormat": "-",
"patterns": {
"d": "dd-mm-yy"
},
"month": {
"currentText": "Huidige maand"
},
"time": {
"currentText": "Nu"
},
"date": {
"closeText": "Sluiten",
"clear": "Wissen",
"prevText": "Vorige",
"nextText": "Volgende",
"currentText": "Vandaag",
"monthNames": [
"januari",
"februari",
"maart",
"april",
"mei",
"juni",
"juli",
"augustus",
"september",
"oktober",
"november",
"december"
],
"monthNamesShort": [
"jan",
"feb",
"mrt",
"apr",
"mei",
"jun",
"jul",
"aug",
"sep",
"okt",
"nov",
"dec"
],
"dayNames": [
"zondag",
"maandag",
"dinsdag",
"woensdag",
"donderdag",
"vrijdag",
"zaterdag"
],
"dayNamesShort": [
"zon",
"maa",
"din",
"woe",
"don",
"vri",
"zat"
],
"dayNamesMin": [
"zo",
"ma",
"di",
"wo",
"do",
"vr",
"za"
],
"weekHeader": "Wk",
"firstDay": 1,
"isRTL": false,
"showMonthAfterYear": false,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,109 @@
webshims.validityMessages.pl = {
"typeMismatch": {
"defaultMessage": "Wprowadź poprawną wartość.",
"email": "Wprowadź poprawny adres e-mail.",
"url": "Wprowadź poprawny adres URL."
},
"badInput": {
"defaultMessage": "Wprowadź poprawną wartość.",
"number": "Wprowadź numer.",
"date": "Wprowadź datę.",
"time": "Wprowadź czas.",
"range": "Niepoprawny zakres.",
"month": "Wprowadź poprawny miesiąc.",
"datetime-local": "Wprowadź datę i czas."
},
"rangeUnderflow": {
"defaultMessage": "Wartość musi być większa lub równa {%min}.",
"date": "Wartość musi być większa lub równa {%min}.",
"time": "Wartość musi być większa lub równa {%min}.",
"datetime-local": "Wartość musi być większa lub równa {%min}.",
"month": "Wartość musi być większa lub równa {%min}."
},
"rangeOverflow": {
"defaultMessage": "Wartość musi być mniejsza lub równa {%max}.",
"date": "Wartość musi być mniejsza lub równa {%max}.",
"time": "Wartość musi być mniejsza lub równa {%max}.",
"datetime-local": "Wartość musi być mniejsza lub równa {%max}.",
"month": "Wartość musi być mniejsza lub równa {%max}."
},
"stepMismatch": "Nieprawidłowe dane.",
"tooLong": "Można wpisać maksymalnie {%maxlength} znaki(ów). Wpisano {%valueLen}.",
"patternMismatch": "Niewłaściwe dane. {%title}",
"valueMissing": {
"defaultMessage": "Proszę wypełnić pole.",
"checkbox": "Zaznacz to pole jeśli chcesz przejść dalej.",
"select": "Wybierz opcję..",
"radio": "Zaznacz opcję."
}
};
webshims.formcfg.pl = {
"numberFormat": {
".": ".",
",": ","
},
"numberSigns": ".-",
"dateSigns": "-",
"timeSigns": ":. ",
"dFormat": "-",
"patterns": {
"d": "yy-mm-dd"
},
"month": {
"currentText": "Bieżący miesiąc"
},
"week": {
"currentText": "Bieżący tydzień"
},
"date": {
"closeText": "Ok",
"clear": "Czyść",
"prevText": "Poprzedni",
"nextText": "Następny",
"currentText": "Dziś",
"monthNames": [
"Styczeń",
"Luty",
"Marzec",
"Kwieceń",
"Maj",
"Czerwiec",
"Lipiec",
"Sierpień",
"Wrzesień",
"Październik",
"Listopad",
"Grudzień"
],
"monthNamesShort": [
"Sty",
"Lut",
"Mar",
"Kwi",
"Maj",
"Cze",
"Lip",
"Sie",
"Wrz",
"Paź",
"Lis",
"Gru"
],
"dayNames": [
"Niedziela",
"Poniedziałek",
"Wtorek",
"Środa",
"Czwartek",
"Piątek",
"Sobota"
],
"dayNamesShort": ["Nie", "Pon", "Wto", "Śro", "Czw", "Pią", "Sob"],
"dayNamesMin": ["Nd", "Pn", "Wt", "Śr", "Cz", "Pt", "So"],
"weekHeader": "Tdz",
"firstDay": 1,
"isRTL": false,
"showMonthAfterYear": true,
"yearSuffix": ""
}
};

View File

@ -0,0 +1,71 @@
webshims.validityMessages["pt-BR"] = {
"typeMismatch": {
"email": "Por favor informe o e-mail.",
"url": "Por favor informe a URL."
},
"badInput": {
"defaultMessage": "Valor inválido.",
"number": "Valor inválido.",
"date": "Data inválida.",
"time": "Hora inválida.",
"range": "Valor inválido.",
"datetime-local": "Data inválida."
},
"tooLong": "Valor inválido.",
"patternMismatch": "Por favor informe no formato: {%title}.",
"valueMissing": {
"defaultMessage": "Por favor preencha este campo.",
"checkbox": "Por favor selecione esta caixa se deseja continuar.",
"select": "Por favor selecione um item da lista.",
"radio": "Por favor selecione uma destas opções."
},
"rangeUnderflow": {
"defaultMessage": "O valor tem de ser superior ou igual a {%min}.",
"date": "O valor tem de ser superior ou igual a {%min}.",
"time": "O valor tem de ser superior ou igual a {%min}.",
"datetime-local": "O valor tem de ser superior ou igual a {%min}."
},
"rangeOverflow": {
"defaultMessage": "O valor tem de ser inferior ou igual a {%max}.",
"date": "O valor tem de ser inferior ou igual a {%max}.",
"time": "O valor tem de ser inferior ou igual a {%max}.",
"datetime-local": "O valor tem de ser inferior ou igual a {%max}."
},
"stepMismatch": "Valor inválido."
};
webshims.formcfg["pt-BR"] = {
numberFormat: {
",": ".",
".": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
month: {
currentText: 'Este mês'
},
time: {
currentText: "Agora"
},
date: {
closeText: "Feito",
clear: 'Limpa',
prevText: "Próximo",
nextText: "Anterior",
currentText: "Hoje",
monthNames: ["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],
monthNamesShort: ["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],
dayNames: ["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sábado"],
dayNamesShort: ["Dom","Seg","Ter","Qua","Qui","Sex","Sab"],
dayNamesMin: ["Do","Se","Te","Qa","Qi","Se","Sa"],
weekHeader: "Sem",
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ""
}
};

View File

@ -0,0 +1,66 @@
webshims.validityMessages["pt-PT"] = {
"typeMismatch": {
"email": "Por favor escreva um endereço de correio.",
"url": "Por favor escreva o URL."
},
"badInput": {
"defaultMessage": "Valor inválido.",
"number": "Valor inválido.",
"date": "Valor inválido.",
"time": "Valor inválido.",
"range": "Valor inválido.",
"datetime-local": "Valor inválido."
},
"tooLong": "Valor inválido.",
"patternMismatch": "Por favor corresponda ao formato pedido: {%title}.",
"valueMissing": {
"defaultMessage": "Por favor preencha este campo.",
"checkbox": "Por favor seleccione esta caixa se deseja continuar.",
"select": "Por favor seleccione um item da lista.",
"radio": "Por favor seleccione uma destas opções."
},
"rangeUnderflow": {
"defaultMessage": "O valor tem de ser superior ou igual a {%min}.",
"date": "O valor tem de ser superior ou igual a {%min}.",
"time": "O valor tem de ser superior ou igual a {%min}.",
"datetime-local": "O valor tem de ser superior ou igual a {%min}."
},
"rangeOverflow": {
"defaultMessage": "O valor tem de ser inferior ou igual a {%max}.",
"date": "O valor tem de ser inferior ou igual a {%max}.",
"time": "O valor tem de ser inferior ou igual a {%max}.",
"datetime-local": "O valor tem de ser inferior ou igual a {%max}."
},
"stepMismatch": "Valor inválido."
};
webshims.formcfg["pt-PT"] = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
date: {
closeText: 'Fechar',
prevText: '&#x3C;Anterior',
nextText: 'Seguinte',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
weekHeader: 'Sem',
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,66 @@
webshims.validityMessages["pt"] = {
"typeMismatch": {
"email": "Por favor escreva um endereço de correio.",
"url": "Por favor escreva o URL."
},
"badInput": {
"defaultMessage": "Valor inválido.",
"number": "Valor inválido.",
"date": "Valor inválido.",
"time": "Valor inválido.",
"range": "Valor inválido.",
"datetime-local": "Valor inválido."
},
"tooLong": "Valor inválido.",
"patternMismatch": "Por favor corresponda ao formato pedido: {%title}.",
"valueMissing": {
"defaultMessage": "Por favor preencha este campo.",
"checkbox": "Por favor seleccione esta caixa se deseja continuar.",
"select": "Por favor seleccione um item da lista.",
"radio": "Por favor seleccione uma destas opções."
},
"rangeUnderflow": {
"defaultMessage": "O valor tem de ser superior ou igual a {%min}.",
"date": "O valor tem de ser superior ou igual a {%min}.",
"time": "O valor tem de ser superior ou igual a {%min}.",
"datetime-local": "O valor tem de ser superior ou igual a {%min}."
},
"rangeOverflow": {
"defaultMessage": "O valor tem de ser inferior ou igual a {%max}.",
"date": "O valor tem de ser inferior ou igual a {%max}.",
"time": "O valor tem de ser inferior ou igual a {%max}.",
"datetime-local": "O valor tem de ser inferior ou igual a {%max}."
},
"stepMismatch": "Valor inválido."
};
webshims.formcfg["pt"] = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '/',
timeSigns: ":. ",
dFormat: "/",
patterns: {
d: "dd/mm/yy"
},
date: {
closeText: 'Fechar',
prevText: '&#x3C;Anterior',
nextText: 'Seguinte',
currentText: 'Hoje',
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
weekHeader: 'Sem',
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages.ru = {
"typeMismatch": {
"email": "Пожалуйста, введите адрес e-mail.",
"url": "Пожалуйста, введите адрес веб-страницы (URL)."
},
"badInput": {
"number": "Пожалуйста, введите число.",
"date": "Пожалуйста, введите дату.",
"time": "Пожалуйста, введите время.",
"range": "Введено неправильное значение.",
"datetime-local": "Пожалуйста, введите дату и время."
},
"tooLong": "Пожалуйста, введите не более {%maxlength} символов(а). Вы ввели {%valueLen}.",
"patternMismatch": "Неправильное значение. {%title}",
"valueMissing": {
"defaultMessage": "Пожалуйста, заполните это поле.",
"checkbox": "Пожалуйста, включите этот переключатель, если хотите продолжить.",
"select": "Пожалуйста, выберите значение.",
"radio": "Пожалуйста, выберите значение."
},
"rangeUnderflow": {
"defaultMessage": "Значение должно быть больше или равно {%min}.",
"date": "Дата должна быть {%min} или более поздняя.",
"time": "Время должно быть {%min} или более позднее.",
"datetime-local": "Значение должно быть {%min} или более позднее."
},
"rangeOverflow": {
"defaultMessage": "Значение должно быть меньше или равно {%max}.",
"date": "Дата должна быть {%max} или более ранняя.",
"time": "Вермя должно быть {%max} или более раннее.",
"datetime-local": "Значение должно быть {%max} или более раннее."
},
"stepMismatch": "Неправильное значение."
};
webshims.formcfg.ru = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '.',
timeSigns: ":. ",
dFormat: ".",
patterns: {
d: 'dd.mm.yy'
},
date: {
closeText: 'Закрыть',
prevText: '&#x3C;Пред',
nextText: 'След&#x3E;',
currentText: 'Сегодня',
monthNames: ['Январь','Февраль','Март','Апрель','Май','Июнь',
'Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
monthNamesShort: ['Янв','Фев','Мар','Апр','Май','Июн',
'Июл','Авг','Сен','Окт','Ноя','Дек'],
dayNames: ['воскресенье','понедельник','вторник','среда','четверг','пятница','суббота'],
dayNamesShort: ['вск','пнд','втр','срд','чтв','птн','сбт'],
dayNamesMin: ['Вс','Пн','Вт','Ср','Чт','Пт','Сб'],
weekHeader: 'Нед',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,73 @@
webshims.validityMessages.sv = {
"typeMismatch": {
"defaultMessage": "Fyll i det här fältet.",
"email": "Fyll i en e-postadress.",
"url": "Fyll i en URL."
},
"badInput": {
"defaultMessage": "Fyll i det här fältet.",
"number": "Fyll i ett nummer.",
"date": "Fyll i en datum.",
"time": "Fyll i en tid.",
"range": "Felaktig inmatning.",
"month": "Fyll i en månad.",
"datetime-local": "Fyll i datum och tid."
},
"tooLong": "Fyll i max {%maxlength} tecken. Du fyllde i {%valueLen}.",
"tooShort": "Fyll i minst {%minlength} tecken. Du fyllde i {%valueLen}.",
"patternMismatch": "Felaktig inmatning. {%title}",
"valueMissing": {
"defaultMessage": "Fyll i detta fält.",
"checkbox": "Bocka denna ruta för att gå vidare.",
"select": "Välj något ur listan.",
"radio": "Välj ett av valen."
},
"rangeUnderflow": {
"defaultMessage": "Värdet måste vara större eller lika med {%min}.",
"date": "Datumet måste vara efter eller lika med {%min}.",
"time": "Tiden måste vara efter eller lika med {%min}.",
"datetime-local": "Värdet måste vara efter eller lika med {%min}.",
"month": "Värdet måste vara efter eller lika med {%min}."
},
"rangeOverflow": {
"defaultMessage": "Värdet måste vara mindre eller lika med {%max}.",
"date": "Datumet måste vara före eller lika med {%max}.",
"time": "Tiden måste vara före eller lika med {%max}.",
"datetime-local": "Värdet måste vara före eller lika med {%max}.",
"month": "Värdet måste vara före eller lika med {%max}."
},
"stepMismatch": "Felaktig inmatning."
};
webshims.formcfg.sv = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '-',
timeSigns: ":. ",
dFormat: "-",
patterns: {
d: "yy-mm-dd"
},
date: {
closeText: 'Stäng',
clear: "Rensa",
prevText: '&#xAB;Förra',
nextText: 'Nästa&#xBB;',
currentText: 'Idag',
monthNames: ['Januari','Februari','Mars','April','Maj','Juni',
'Juli','Augusti','September','Oktober','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Maj','Jun',
'Jul','Aug','Sep','Okt','Nov','Dec'],
dayNamesShort: ['Sön','Mån','Tis','Ons','Tor','Fre','Lör'],
dayNames: ['Söndag','Måndag','Tisdag','Onsdag','Torsdag','Fredag','Lördag'],
dayNamesMin: ['Sö','Må','Ti','On','To','Fr','Lö'],
weekHeader: 'Ve',
dateFormat: 'yy-mm-dd',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
}
};

View File

@ -0,0 +1,65 @@
webshims.validityMessages['zh-CN'] = {
"typeMismatch": {
"email": "请输入电子邮件地址。",
"url": "请输入一个 URL。"
},
"badInput": {
"number": "值无效。",
"date": "值无效。",
"time": "值无效。",
"range": "值无效。",
"datetime-local": "值无效。"
},
"tooLong": "值无效。",
"patternMismatch": "请匹配要求的格式: {%title}。",
"valueMissing": {
"defaultMessage": "请填写此字段。",
"checkbox": "若要继续,请检选此检查框。",
"select": "请选择列表中的一项。",
"radio": "请选择一个选项。"
},
"rangeUnderflow": {
"defaultMessage": "值无效。",
"date": "值无效。",
"time": "值无效。",
"datetime-local": "值无效。"
},
"rangeOverflow": {
"defaultMessage": "值无效。",
"date": "值无效。",
"time": "值无效。",
"datetime-local": "值无效。"
},
"stepMismatch": "值无效。"
};
webshims.formcfg['zh-CN'] = {
numberFormat: {
".": ".",
",": ","
},
numberSigns: '.',
dateSigns: '-',
timeSigns: ":. ",
dFormat: "-",
patterns: {
d: "yy-mm-dd"
},
date: {
closeText: '关闭',
prevText: '&#x3C;上月',
nextText: '下月&#x3E;',
currentText: '今天',
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
weekHeader: '周',
firstDay: 1,
isRTL: false,
showMonthAfterYear: true,
yearSuffix: '年'
}
};

View File

@ -0,0 +1,130 @@
webshims.validityMessages['zh-TW'] = {
"typeMismatch": {
"defaultMessage": "請輸入一個正確的值。",
"email": "請輸入一個電子郵件地址。",
"url": "請輸入一個網址。"
},
"badInput": {
"defaultMessage": "請輸入一個正確的值。",
"number": "請輸入一個數字。",
"date": "請輸入一個日期。",
"time": "請輸入一個時間。",
"range": "無效的值。",
"month": "請輸入一個正確的值。",
"datetime-local": "請輸入一個正確的日期和時間。"
},
"rangeUnderflow": {
"defaultMessage": "輸入的值必需大過或等於 {%min}。",
"date": "輸入的值必需在 {%min} 或之後。",
"time": "輸入的值必需在 {%min} 或之後。",
"datetime-local": "輸入的值必需在 {%min} 或之後。",
"month": "輸入的值必需在 {%min} 或之後。"
},
"rangeOverflow": {
"defaultMessage": "輸入的值必需小過或等於 {%max}。",
"date": "輸入的值必需在 {%max} 或之前。",
"time": "輸入的值必需在 {%max} 或之前。",
"datetime-local": "輸入的值必需在 {%max} 或之前。",
"month": "輸入的值必需在 {%max} 或之前。"
},
"stepMismatch": "無效的輸入。",
"tooLong": "請輸入 {%maxlength} 字元或更小。你輸入了 {%valueLen} 字元。",
"tooShort": "請輸入 {%minlength} 字元或更多。你輸入了 {%valueLen} 字元。",
"patternMismatch": "無效的輸入。{%title}",
"valueMissing": {
"defaultMessage": "請填寫此欄位。",
"checkbox": "請核取此方塊以繼續。",
"select": "請選取一個選擇。",
"radio": "請選取一個選擇。"
}
};
webshims.formcfg['zh-TW'] = {
"numberFormat": {
".": ".",
",": ","
},
"numberSigns": '.',
"dateSigns": '-',
"timeSigns": ":. ",
"dFormat": "-",
"patterns": {
"d": "yy-mm-dd"
},
"meridian": [
"上午",
"下午"
],
"month": {
"currentText": "本月"
},
"time": {
"currentText": "現在"
},
"date": {
"closeText": "完成",
"clear": "清除",
"prevText": "上",
"nextText": "下",
"currentText": "今日",
"monthNames": [
"一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月"
],
"monthNamesShort": [
"一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月"
],
"dayNames": [
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六"
],
"dayNamesShort": [
"周日",
"周一",
"周二",
"周三",
"周四",
"周五",
"周六"
],
"dayNamesMin": [
"日",
"一",
"二",
"三",
"四",
"五",
"六"
],
"weekHeader": "週",
"firstDay": 0,
"isRTL": false,
"showMonthAfterYear": true,
"yearSuffix": "年"
}
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,189 @@
%iconbase {
font-family: 'jme';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
zoom: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
%icon-spinner {
@extend %iconbase;
&:before {
content: "\e612";
}
}
%icon-expand {
@extend %iconbase;
&:before {
content: "\e604";
}
}
%icon-contract {
@extend %iconbase;
&:before {
content: "\e605";
}
}
%icon-config {
@extend %iconbase;
&:before {
content: "\e606";
}
}
%icon-list {
@extend %iconbase;
&:before {
content: "\e607";
}
}
%icon-play-circle {
@extend %iconbase;
&:before {
content: "\e608";
}
}
%icon-pause-circle {
@extend %iconbase;
&:before {
content: "\e609";
}
}
%icon-play {
@extend %iconbase;
&:before {
content: "\e60a";
}
}
%icon-pause {
@extend %iconbase;
&:before {
content: "\e60b";
}
}
%icon-volume-high {
@extend %iconbase;
&:before {
content: "\e60c";
}
}
%icon-volume-medium {
@extend %iconbase;
&:before {
content: "\e60d";
}
}
%icon-volume-low {
@extend %iconbase;
&:before {
content: "\e60e";
}
}
%icon-volume-mute {
@extend %iconbase;
&:before {
content: "\e60f";
}
}
%icon-volume-mute2 {
@extend %iconbase;
&:before {
content: "\e610";
}
}
%icon-share {
@extend %iconbase;
&:before {
content: "\e611";
}
}
%icon-play3 {
@extend %iconbase;
&:before {
content: "\e614";
}
}
%icon-cc {
@extend %iconbase;
&:before {
content: "\e600";
}
}
%icon-checkbox-checked {
@extend %iconbase;
&:before {
content: "\e616";
}
}
%icon-checkbox-unchecked {
@extend %iconbase;
&:before {
content: "\e617";
}
}
%icon-code {
@extend %iconbase;
&:before {
content: "\e619";
}
}
%icon-disk {
@extend %iconbase;
&:before {
content: "\e613";
}
}
%icon-next {
@extend %iconbase;
&:before {
content: "\e602";
}
}
%icon-previous {
@extend %iconbase;
&:before {
content: "\e603";
}
}
%icon-olist {
@extend %iconbase;
&:before {
content: "\e615";
}
}
%icon-loop {
@extend %iconbase;
&:before {
content: "\e601";
}
}

Some files were not shown because too many files have changed in this diff Show More