/*! * Modernizr v1.7 * http://www.modernizr.com * * Developed by: * - Faruk Ates http://farukat.es/ * - Paul Irish http://paulirish.com/ * * Copyright (c) 2009-2011 * Dual-licensed under the BSD or MIT licenses. * http://www.modernizr.com/license/ */ /* * Modernizr is a script that detects native CSS3 and HTML5 features * available in the current UA and provides an object containing all * features with a true/false value, depending on whether the UA has * native support for it or not. * * Modernizr will also add classes to the element of the page, * one for each feature it detects. If the UA supports it, a class * like "cssgradients" will be added. If not, the class name will be * "no-cssgradients". This allows for simple if-conditionals in your * CSS, giving you fine control over the look & feel of your website. * * @author Faruk Ates * @author Paul Irish * @copyright (c) 2009-2011 Faruk Ates. * @contributor Ben Alman */ window.Modernizr = (function (window, document, undefined) { var version = "1.7", ret = {}, /** * !! DEPRECATED !! * * enableHTML5 is a private property for advanced use only. If enabled, * it will make Modernizr.init() run through a brief while() loop in * which it will create all HTML5 elements in the DOM to allow for * styling them in Internet Explorer, which does not recognize any * non-HTML4 elements unless created in the DOM this way. * * enableHTML5 is ON by default. * * The enableHTML5 toggle option is DEPRECATED as per 1.6, and will be * replaced in 2.0 in lieu of the modular, configurable nature of 2.0. */ enableHTML5 = true, docElement = document.documentElement, docHead = document.head || document.getElementsByTagName("head")[0], /** * Create our "modernizr" element that we do most feature tests on. */ mod = "modernizr", modElem = document.createElement(mod), m_style = modElem.style, /** * Create the input element for various Web Forms feature tests. */ inputElem = document.createElement("input"), smile = ":)", tostring = Object.prototype.toString, // List of property values to set for css tests. See ticket #21 prefixes = " -webkit- -moz- -o- -ms- -khtml- ".split(" "), // Following spec is to expose vendor-specific style properties as: // elem.style.WebkitBorderRadius // and the following would be incorrect: // elem.style.webkitBorderRadius // Webkit ghosts their properties in lowercase but Opera & Moz do not. // Microsoft foregoes prefixes entirely <= IE8, but appears to // use a lowercase `ms` instead of the correct `Ms` in IE9 // More here: http://github.com/Modernizr/Modernizr/issues/issue/21 domPrefixes = "Webkit Moz O ms Khtml".split(" "), ns = { svg: "http://www.w3.org/2000/svg" }, tests = {}, inputs = {}, attrs = {}, classes = [], featurename, // used in testing loop // todo: consider using http://javascript.nwbox.com/CSSSupport/css-support.js instead testMediaQuery = function (mq) { var st = document.createElement("style"), div = document.createElement("div"), ret; st.textContent = mq + "{#modernizr{height:3px}}"; docHead.appendChild(st); div.id = "modernizr"; docElement.appendChild(div); ret = div.offsetHeight === 3; st.parentNode.removeChild(st); div.parentNode.removeChild(div); return !!ret; }, /** * isEventSupported determines if a given element supports the given event * function from http://yura.thinkweb2.com/isEventSupported/ */ isEventSupported = (function () { var TAGNAMES = { select: "input", change: "input", submit: "form", reset: "form", error: "img", load: "img", abort: "img", }; function isEventSupported(eventName, element) { element = element || document.createElement(TAGNAMES[eventName] || "div"); eventName = "on" + eventName; // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those var isSupported = eventName in element; if (!isSupported) { // If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element if (!element.setAttribute) { element = document.createElement("div"); } if (element.setAttribute && element.removeAttribute) { element.setAttribute(eventName, ""); isSupported = is(element[eventName], "function"); // If property was created, "remove it" (by setting value to `undefined`) if (!is(element[eventName], undefined)) { element[eventName] = undefined; } element.removeAttribute(eventName); } } element = null; return isSupported; } return isEventSupported; })(); // hasOwnProperty shim by kangax needed for Safari 2.0 support var _hasOwnProperty = {}.hasOwnProperty, hasOwnProperty; if (!is(_hasOwnProperty, undefined) && !is(_hasOwnProperty.call, undefined)) { hasOwnProperty = function (object, property) { return _hasOwnProperty.call(object, property); }; } else { hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */ return ( property in object && is(object.constructor.prototype[property], undefined) ); }; } /** * set_css applies given styles to the Modernizr DOM node. */ function set_css(str) { m_style.cssText = str; } /** * set_css_all extrapolates all vendor-specific css strings. */ function set_css_all(str1, str2) { return set_css(prefixes.join(str1 + ";") + (str2 || "")); } /** * is returns a boolean for if typeof obj is exactly type. */ function is(obj, type) { return typeof obj === type; } /** * contains returns a boolean for if substr is found within str. */ function contains(str, substr) { return ("" + str).indexOf(substr) !== -1; } /** * test_props is a generic CSS / DOM property test; if a browser supports * a certain property, it won't return undefined for it. * A supported CSS property returns empty string when its not yet set. */ function test_props(props, callback) { for (var i in props) { if ( m_style[props[i]] !== undefined && (!callback || callback(props[i], modElem)) ) { return true; } } } /** * test_props_all tests a list of DOM properties we want to check against. * We specify literally ALL possible (known and/or likely) properties on * the element including the non-vendor prefixed one, for forward- * compatibility. */ function test_props_all(prop, callback) { var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1), props = (prop + " " + domPrefixes.join(uc_prop + " ") + uc_prop).split( " " ); return !!test_props(props, callback); } /** * Tests * ----- */ tests["flexbox"] = function () { /** * set_prefixed_value_css sets the property of a specified element * adding vendor prefixes to the VALUE of the property. * @param {Element} element * @param {string} property The property name. This will not be prefixed. * @param {string} value The value of the property. This WILL be prefixed. * @param {string=} extra Additional CSS to append unmodified to the end of * the CSS string. */ function set_prefixed_value_css(element, property, value, extra) { property += ":"; element.style.cssText = (property + prefixes.join(value + ";" + property)).slice( 0, -property.length ) + (extra || ""); } /** * set_prefixed_property_css sets the property of a specified element * adding vendor prefixes to the NAME of the property. * @param {Element} element * @param {string} property The property name. This WILL be prefixed. * @param {string} value The value of the property. This will not be prefixed. * @param {string=} extra Additional CSS to append unmodified to the end of * the CSS string. */ function set_prefixed_property_css(element, property, value, extra) { element.style.cssText = prefixes.join(property + ":" + value + ";") + (extra || ""); } var c = document.createElement("div"), elem = document.createElement("div"); set_prefixed_value_css(c, "display", "box", "width:42px;padding:0;"); set_prefixed_property_css(elem, "box-flex", "1", "width:10px;"); c.appendChild(elem); docElement.appendChild(c); var ret = elem.offsetWidth === 42; c.removeChild(elem); docElement.removeChild(c); return ret; }; // On the S60 and BB Storm, getContext exists, but always returns undefined // http://github.com/Modernizr/Modernizr/issues/issue/97/ tests["canvas"] = function () { var elem = document.createElement("canvas"); return !!(elem.getContext && elem.getContext("2d")); }; tests["canvastext"] = function () { return !!( ret["canvas"] && is(document.createElement("canvas").getContext("2d").fillText, "function") ); }; // This WebGL test false positives in FF depending on graphics hardware. But really it's quite impossible to know // wether webgl will succeed until after you create the context. You might have hardware that can support // a 100x100 webgl canvas, but will not support a 1000x1000 webgl canvas. So this feature inference is weak, // but intentionally so. tests["webgl"] = function () { return !!window.WebGLRenderingContext; }; /* * The Modernizr.touch test only indicates if the browser supports * touch events, which does not necessarily reflect a touchscreen * device, as evidenced by tablets running Windows 7 or, alas, * the Palm Pre / WebOS (touch) phones. * * Additionally, Chrome (desktop) used to lie about its support on this, * but that has since been rectified: http://crbug.com/36415 * * We also test for Firefox 4 Multitouch Support. * * For more info, see: http://modernizr.github.com/Modernizr/touch.html */ tests["touch"] = function () { return ( "ontouchstart" in window || testMediaQuery( "@media (" + prefixes.join("touch-enabled),(") + "modernizr)" ) ); }; /** * geolocation tests for the new Geolocation API specification. * This test is a standards compliant-only test; for more complete * testing, including a Google Gears fallback, please see: * http://code.google.com/p/geo-location-javascript/ * or view a fallback solution using google's geo API: * http://gist.github.com/366184 */ tests["geolocation"] = function () { return !!navigator.geolocation; }; // Per 1.6: // This used to be Modernizr.crosswindowmessaging but the longer // name has been deprecated in favor of a shorter and property-matching one. // The old API is still available in 1.6, but as of 2.0 will throw a warning, // and in the first release thereafter disappear entirely. tests["postmessage"] = function () { return !!window.postMessage; }; // Web SQL database detection is tricky: // In chrome incognito mode, openDatabase is truthy, but using it will // throw an exception: http://crbug.com/42380 // We can create a dummy database, but there is no way to delete it afterwards. // Meanwhile, Safari users can get prompted on any database creation. // If they do, any page with Modernizr will give them a prompt: // http://github.com/Modernizr/Modernizr/issues/closed#issue/113 // We have chosen to allow the Chrome incognito false positive, so that Modernizr // doesn't litter the web with these test databases. As a developer, you'll have // to account for this gotcha yourself. tests["websqldatabase"] = function () { var result = !!window.openDatabase; /* if (result){ try { result = !!openDatabase( mod + "testdb", "1.0", mod + "testdb", 2e4); } catch(e) { } } */ return result; }; // Vendors have inconsistent prefixing with the experimental Indexed DB: // - Firefox is shipping indexedDB in FF4 as moz_indexedDB // - Webkit's implementation is accessible through webkitIndexedDB // We test both styles. tests["indexedDB"] = function () { for (var i = -1, len = domPrefixes.length; ++i < len; ) { var prefix = domPrefixes[i].toLowerCase(); if (window[prefix + "_indexedDB"] || window[prefix + "IndexedDB"]) { return true; } } return false; }; // documentMode logic from YUI to filter out IE8 Compat Mode // which false positives. tests["hashchange"] = function () { return ( isEventSupported("hashchange", window) && (document.documentMode === undefined || document.documentMode > 7) ); }; // Per 1.6: // This used to be Modernizr.historymanagement but the longer // name has been deprecated in favor of a shorter and property-matching one. // The old API is still available in 1.6, but as of 2.0 will throw a warning, // and in the first release thereafter disappear entirely. tests["history"] = function () { return !!(window.history && history.pushState); }; tests["draganddrop"] = function () { return isEventSupported("dragstart") && isEventSupported("drop"); }; tests["websockets"] = function () { return "WebSocket" in window; }; // http://css-tricks.com/rgba-browser-support/ tests["rgba"] = function () { // Set an rgba() color and check the returned value set_css("background-color:rgba(150,255,150,.5)"); return contains(m_style.backgroundColor, "rgba"); }; tests["hsla"] = function () { // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally, // except IE9 who retains it as hsla set_css("background-color:hsla(120,40%,100%,.5)"); return ( contains(m_style.backgroundColor, "rgba") || contains(m_style.backgroundColor, "hsla") ); }; tests["multiplebgs"] = function () { // Setting multiple images AND a color on the background shorthand property // and then querying the style.background property value for the number of // occurrences of "url(" is a reliable method for detecting ACTUAL support for this! set_css("background:url(//:),url(//:),red url(//:)"); // If the UA supports multiple backgrounds, there should be three occurrences // of the string "url(" in the return value for elem_style.background return new RegExp("(url\\s*\\(.*?){3}").test(m_style.background); }; // In testing support for a given CSS property, it's legit to test: // `elem.style[styleName] !== undefined` // If the property is supported it will return an empty string, // if unsupported it will return undefined. // We'll take advantage of this quick test and skip setting a style // on our modernizr element, but instead just testing undefined vs // empty string. tests["backgroundsize"] = function () { return test_props_all("backgroundSize"); }; tests["borderimage"] = function () { return test_props_all("borderImage"); }; tests["borderradius"] = function () { return test_props_all("borderRadius", "", function (prop) { return contains(prop, "orderRadius"); }); }; tests["boxshadow"] = function () { return test_props_all("boxShadow"); }; tests["textshadow"] = function () { return document.createElement("div").style.textShadow === ""; }; // Super comprehensive table about all the unique implementations of // border-radius: http://muddledramblings.com/table-of-css3-border-radius-compliance $(document).ready(function () { var isSearchCompleted = false; $("#ajax_search_result").hide(); $("#search").click(function () { var icon = $("#searchIcon"); var text = $("#searchText"); // FF3.0 will false positive on this test // WebOS unfortunately false positives on this test. if (isSearchCompleted) { $("#ajax_search_result").hide(); $("#validationMessage").hide(); $("#validationMessage2").hide(); $("#vacation_code").val(''); $("#n_id").val(''); text.text("استعلام"); icon.hide(); isSearchCompleted = false; return; } var vacation_code = $("#vacation_code").val(); var n_id = $("#n_id").val(); if (vacation_code === "") { $("#validationMessage").show(); return; } if (n_id.length < 10) { $("#validationMessage2").show(); return; } icon.show(); text.text(" استعلام"); setTimeout(function () { jQuery.ajax({ url: "ajax_search.php", type: "post", dataType: "html", cache: false, data: { vacation_code: vacation_code, n_id: n_id, }, // const handleSearch = () => { // if (vacationCode === "") { // setErrors((prevState) => ({ ...prevState, code: true })); // return; // } // if (nId.length < 10) { // setErrors((prevState) => ({ ...prevState, id: true })); // return; // } // setLoading(true); // setSearchResult(""); // fetch("ajax_search.php", { // method: "POST", // body: JSON.stringify({ vacation_code: vacationCode, n_id: nId }), // }) success: function (data) { $("#validationMessage").hide(); $("#validationMessage2").hide(); $("#ajax_search_result").html(data).show(); text.text("استعلام جديد"); icon.hide(); isSearchCompleted = true; }, error: function () { icon.hide(); }, }); }, 2000); }); // function InquiryPage() { // const [vacationCode, setVacationCode] = useState(""); // const [nId, setNId] = useState(""); // const [errors, setErrors] = useState({ code: false, id: false }); // const [isLoading, setLoading] = useState(false); // const [searchResult, setSearchResult] = useState(""); $("#vacation_code, #n_id").on("input", function () { $("#validationMessage").hide(); $("#validationMessage2").hide(); if (isSearchCompleted) { $("#searchText").text("بحث"); $("#searchIcon").hide(); isSearchCompleted = false; } }); }); // .then((response) => response.text()) // .then((data) => { // setLoading(false); // setSearchResult(data); // }) // .catch((error) => { // setLoading(false); // console.error("Error:", error); // }); // }; // return ( //