X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo.js;h=612a227566dab5a6e3e27096fe2ced6458e6df65;hp=f9116531501b4ab13286665aa133267af3e1c8c1;hb=c47e24f9bde6e0a7a5994c0024daa13e7e4df117;hpb=367242064a76e38e96ebebed21701363a4f8299f diff --git a/Roo.js b/Roo.js index f911653150..612a227566 100644 --- a/Roo.js +++ b/Roo.js @@ -19,7 +19,7 @@ window["undefined"] = window["undefined"]; /** * @class Roo * Roo core utilities and functions. - * @singleton + * @static */ var Roo = {}; /** @@ -53,15 +53,35 @@ Roo.apply = function(o, c, defaults){ var isStrict = document.compatMode == "CSS1Compat", isOpera = ua.indexOf("opera") > -1, isSafari = (/webkit|khtml/).test(ua), + isFirefox = ua.indexOf("firefox") > -1, isIE = ua.indexOf("msie") > -1, isIE7 = ua.indexOf("msie 7") > -1, + isIE11 = /trident.*rv\:11\./.test(ua), + isEdge = ua.indexOf("edge") > -1, isGecko = !isSafari && ua.indexOf("gecko") > -1, isBorderBox = isIE && !isStrict, isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1), isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1), isLinux = (ua.indexOf("linux") != -1), - isSecure = window.location.href.toLowerCase().indexOf("https") === 0; - + isSecure = window.location.href.toLowerCase().indexOf("https") === 0, + isIOS = /iphone|ipad/.test(ua), + isAndroid = /android/.test(ua), + isTouch = (function() { + try { + if (ua.indexOf('chrome') != -1 && ua.indexOf('android') == -1) { + window.addEventListener('touchstart', function __set_has_touch__ () { + Roo.isTouch = true; + window.removeEventListener('touchstart', __set_has_touch__); + }); + return false; // no touch on chrome!? + } + document.createEvent("TouchEvent"); + return true; + } catch (e) { + return false; + } + + })(); // remove css image flicker if(isIE && !isIE7){ try{ @@ -120,127 +140,7 @@ Roo.apply = function(o, c, defaults){ BLANK_IMAGE_URL : "http:/"+"/localhost/s.gif", emptyFn : function(){}, - /** - * Deep object/array copy. Function clones are actually wrappers around the - * original function. Array-like objects are treated as arrays. Primitives are - * returned untouched. Optionally, a function can be provided to handle other data - * types, filter keys, validate values, etc. - * - * **Note:** Cloning a non-trivial object is a reasonably heavy operation, due to - * the need to recursively iterate down non-primitive properties. Clone should be - * used only when a deep clone down to leaf level properties is explicitly - * required. This method will also - * - In many cases (for example, when trying to isolate objects used as hashes for - configuration properties), a shallow copy, using `Y.merge()` is normally - sufficient. If more than one level of isolation is required, `Y.merge()` can be - used selectively at each level which needs to be isolated from the original - without going all the way to leaf properties. - - @method clone - @param {object} o what to clone. - @param {boolean} safe if true, objects will not have prototype items from the - source. If false, they will. In this case, the original is initially - protected, but the clone is not completely immune from changes to the source - object prototype. Also, cloned prototype items that are deleted from the - clone will result in the value of the source prototype being exposed. If - operating on a non-safe clone, items should be nulled out rather than - deleted. - @param {function} f optional function to apply to each item in a collection; it - will be executed prior to applying the value to the new object. - Return false to prevent the copy. - @param {object} c optional execution context for f. - @param {object} owner Owner object passed when clone is iterating an object. - Used to set up context for cloned functions. - @param {object} cloned hash of previously cloned objects to avoid multiple - clones. - @return {Array|Object} the cloned object. - **/ - clone : function(o, safe, f, c, owner, cloned) { - var o2, marked, stamp; - - // Does not attempt to clone: - // - // * Non-typeof-object values, "primitive" values don't need cloning. - // - // * YUI instances, cloning complex object like YUI instances is not - // advised, this is like cloning the world. - // - // * DOM nodes (#2528250), common host objects like DOM nodes cannot be - // "subclassed" in Firefox and old versions of IE. Trying to use - // `Object.create()` or `Y.extend()` on a DOM node will throw an error in - // these browsers. - // - // Instad, the passed-in `o` will be return as-is when it matches one of the - // above criteria. -// if (!L.isObject(o) || -// Y.instanceOf(o, YUI) || -// (o.addEventListener || o.attachEvent)) { -// -// return o; -// } - - marked = cloned || {}; - - switch (this.type(o)) { - case 'date': - return new Date(o); - case 'regexp': - // if we do this we need to set the flags too - // return new RegExp(o.source); - return o; - case 'function': - // o2 = Y.bind(o, owner); - // break; - return o; - case 'array': - o2 = []; - break; - default: - - // #2528250 only one clone of a given object should be created. - if (o['_~roo~_']) { - return marked[o['_~roo~_']]; - } - - stamp = Roo.id(); - -// o2 = (safe) ? {} : Roo.Object(o); - o2 = {}; - o['_~roo~_'] = stamp; - marked[stamp] = o; - } - - Roo.each(o, function(v, k) { - if ((k || k === 0) && (!f || (f.call(c || this, v, k, this, o) !== false))) { - if (k !== '_~roo~_') { - if (k == 'prototype') { - // skip the prototype - // } else if (o[k] === o) { - // this[k] = this; - } else { - this[k] = - Roo.clone(v, safe, f, c, owner || o, marked); - } - } - } - }, o2); - - if (!cloned) { - Roo.each(marked, function(v, k) { - if (v['_~roo~_']) { - try { - delete v['_~roo~_']; - } catch (e) { - v['_~roo~_'] = null; - } - } - }, this); - marked = null; - } - - return o2; - }, + /** * Copies all the properties of config to obj if they don't already exist. * @param {Object} obj The receiver of the properties @@ -423,7 +323,7 @@ Roo.factory(conf, Roo.data); return c; } if (ns[c.xtype]) { - if (Roo.debug) Roo.log("Roo.Factory(" + c.xtype + ")"); + if (Roo.debug) { Roo.log("Roo.Factory(" + c.xtype + ")"); } var ret = new ns[c.xtype](c); ret.xns = false; return ret; @@ -442,8 +342,8 @@ Roo.factory(conf, Roo.data); if ((typeof(console) == 'undefined') || (typeof(console.log) == 'undefined')) { return; // alerT? } - console.log(s); + console.log(s); }, /** * Takes an object and converts it to an encoded URL. e.g. Roo.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value. @@ -722,10 +622,16 @@ Roo.factory(conf, Roo.data); /** @type Boolean */ isSafari : isSafari, /** @type Boolean */ + isFirefox : isFirefox, + /** @type Boolean */ isIE : isIE, /** @type Boolean */ isIE7 : isIE7, /** @type Boolean */ + isIE11 : isIE11, + /** @type Boolean */ + isEdge : isEdge, + /** @type Boolean */ isGecko : isGecko, /** @type Boolean */ isBorderBox : isBorderBox, @@ -735,6 +641,12 @@ Roo.factory(conf, Roo.data); isLinux : isLinux, /** @type Boolean */ isMac : isMac, + /** @type Boolean */ + isIOS : isIOS, + /** @type Boolean */ + isAndroid : isAndroid, + /** @type Boolean */ + isTouch : isTouch, /** * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash, @@ -756,7 +668,30 @@ Roo.factory(conf, Roo.data); { var node = Roo.DomQuery.selectNode(selector,root); return node ? Roo.get(node) : new Roo.Element(false); - } + }, + /** + * Find the current bootstrap width Grid size + * Note xs is the default for smaller.. - this is currently used by grids to render correct columns + * @returns {String} (xs|sm|md|lg|xl) + */ + + getGridSize : function() + { + var w = Roo.lib.Dom.getViewWidth(); + switch(true) { + case w > 1200: + return 'xl'; + case w > 992: + return 'lg'; + case w > 768: + return 'md'; + case w > 576: + return 'sm'; + default: + return 'xs' + } + + } }); @@ -764,4 +699,6 @@ Roo.factory(conf, Roo.data); })(); Roo.namespace("Roo", "Roo.util", "Roo.grid", "Roo.dd", "Roo.tree", "Roo.data", - "Roo.form", "Roo.menu", "Roo.state", "Roo.lib", "Roo.layout", "Roo.app", "Roo.ux"); + "Roo.form", "Roo.menu", "Roo.state", "Roo.lib", "Roo.layout", + "Roo.app", "Roo.ux" + );