X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-bootstrap-debug.js;h=ea98f39293ebc9d9850e83975b91a05af6fe48ec;hp=f6d0dbb66319ec49f651186714156e371a49b08c;hb=8f5eb4c4c8c1b9d0a7198e29efe26ac2d9e0bff8;hpb=5f4d0376290a9974047c5ef2897427023524a667 diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index f6d0dbb663..ea98f39293 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -1,4 +1,4 @@ -/** +Roo.bootstrap = {};/** * set the version of bootstrap based on the stylesheet... * */ @@ -14,7 +14,10 @@ Roo.bootstrap.version = ( function() { Roo.Element.prototype.visibilityMode = Roo.Element.DISPLAY; } return ret; -})(); /* +})(); Roo.bootstrap.menu = Roo.bootstrap.menu || {}; +Roo.bootstrap.nav = {}; + +Roo.bootstrap.form = {};Roo.bootstrap.panel = {};Roo.bootstrap.layout = {};/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -95,6 +98,7 @@ Roo.Shadow.prototype = { * frame: Shadow displays equally on all four sides
* drop: Traditional bottom-right drop shadow (default) */ + mode: false, /** * @cfg {String} offset * The number of pixels to offset the shadow from the element (defaults to 4) @@ -222,6 +226,8 @@ Roo.bootstrap = Roo.bootstrap || {}; /** * @class Roo.bootstrap.Component * @extends Roo.Component + * @abstract + * @children Roo.bootstrap.Component * Bootstrap Component base class * @cfg {String} cls css class * @cfg {String} style any extra css @@ -330,11 +336,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, { } if (this.cls) { - cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls; + cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls; } if (this.style) { // fixme needs to support more complex style data. - cfg.style = this.style; + cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style; } if(this.name){ @@ -362,6 +368,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, { { return this.el; }, + getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work + { + return Roo.get(document.body); + }, + /** * Fetch the element to display the tooltip on. * @return {Roo.Element} defaults to this.el @@ -644,12 +655,16 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, { /** * @class Roo.bootstrap.Element * @extends Roo.bootstrap.Component - * Bootstrap Element class + * @children Roo.bootstrap.Component + * Bootstrap Element class (basically a DIV used to make random stuff ) + * * @cfg {String} html contents of the element * @cfg {String} tag tag of the element * @cfg {String} cls class of the element * @cfg {Boolean} preventDefault (true|false) default false * @cfg {Boolean} clickable (true|false) default false + * @cfg {String} role default blank - set to button to force cursor pointer + * * @constructor * Create a new Element @@ -667,7 +682,9 @@ Roo.bootstrap.Element = function(config){ * @param {Roo.bootstrap.Element} this * @param {Roo.EventObject} e */ - "click" : true + "click" : true + + }); }; @@ -678,6 +695,8 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { html: '', preventDefault: false, clickable: false, + tapedTwice : false, + role : false, getAutoCreate : function(){ @@ -686,6 +705,9 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { // cls: this.cls, double assign in parent class Component.js :: onRender html: this.html }; + if (this.role !== false) { + cfg.role = this.role; + } return cfg; }, @@ -698,6 +720,7 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { this.el.on('click', this.onClick, this); } + }, onClick : function(e) @@ -706,9 +729,14 @@ Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, { e.preventDefault(); } - this.fireEvent('click', this, e); + this.fireEvent('click', this, e); // why was this double click before? }, + + + + + getValue : function() { return this.el.dom.innerHTML; @@ -827,6 +855,8 @@ Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, { /** * @class Roo.bootstrap.Body * @extends Roo.bootstrap.Component + * @children Roo.bootstrap.Component + * @parent none builder * Bootstrap Body class * * @constructor @@ -878,6 +908,8 @@ Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, { * @class Roo.bootstrap.ButtonGroup * @extends Roo.bootstrap.Component * Bootstrap ButtonGroup class + * @children Roo.bootstrap.Button Roo.bootstrap.form.Form + * * @cfg {String} size lg | sm | xs (default empty normal) * @cfg {String} align vertical | justified (default none) * @cfg {String} direction up | down (default down) @@ -984,7 +1016,8 @@ Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, { * @cfg {Boolean} removeClass remove the standard class.. * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href. * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup. - * + * @cfg {Roo.bootstrap.menu.Menu} menu a Menu + * @constructor * Create a new button * @param {Object} config The config object @@ -1307,7 +1340,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, { } Roo.log('button on click '); - if(this.preventDefault){ + if(this.href === '' || this.preventDefault){ e.preventDefault(); } @@ -1354,6 +1387,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, { { this.disabled = false; this.el.removeClass('disabled'); + this.el.dom.removeAttribute("disabled"); }, /** @@ -1363,6 +1397,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, { { this.disabled = true; this.el.addClass('disabled'); + this.el.attr("disabled", "disabled") }, /** * sets the active state on/off, @@ -1443,6 +1478,7 @@ Roo.bootstrap.Button.weights = [ /** * @class Roo.bootstrap.Column * @extends Roo.bootstrap.Component + * @children Roo.bootstrap.Component * Bootstrap Column class * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden @@ -1570,6 +1606,8 @@ Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, { /** * @class Roo.bootstrap.Container * @extends Roo.bootstrap.Component + * @children Roo.bootstrap.Component + * @parent builder * Bootstrap Container class * @cfg {Boolean} jumbotron is it a jumbotron element * @cfg {String} html content of element @@ -1933,16 +1971,12 @@ Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, { } }); - /* - * - LGPL - * - * This is BS4's Card element.. - similar to our containers probably.. - * - */ -/** + /** * @class Roo.bootstrap.Card * @extends Roo.bootstrap.Component - * Bootstrap Card class + * @children Roo.bootstrap.Component + * @licence LGPL + * Bootstrap Card class - note this has children as CardHeader/ImageTop/Footer.. - which should really be listed properties? * * * possible... may not be implemented.. @@ -2015,12 +2049,19 @@ Roo.bootstrap.Card = function(config){ /** * @event rotate * When a element a card is rotate - * @param {Roo.bootstrap.Element} this + * @param {Roo.bootstrap.Card} this * @param {Roo.Element} n the node being dropped? * @param {Boolean} rotate status */ - 'rotate' : true - + 'rotate' : true, + /** + * @event cardover + * When a card element is dragged over ready to drop (return false to block dropable) + * @param {Roo.bootstrap.Card} this + * @param {Object} data from dragdrop + */ + 'cardover' : true + }); }; @@ -2075,6 +2116,8 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { bodyEl: false, // card-body headerContainerEl : false, // headerEl : false, + header_imageEl : false, + layoutCls : function() { @@ -2285,7 +2328,7 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { }, getCardImageTop : function() { - var ret = this.el.select('.card-img-top',true).first(); + var ret = this.header_imageEl; if (ret.hasClass('d-none')) { ret.removeClass('d-none'); } @@ -2331,17 +2374,19 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { if (this.rotateable) { this.el.select('.card-header',true).on('click', this.onToggleRotate, this); } - this.collapsableEl = this.el.select('.roo-collapsable').first(); + this.collapsableEl = this.el.select('.roo-collapsable',true).first(); - this.footerEl = this.el.select('.card-footer').first(); - this.collapsableToggleEl = this.el.select('.roo-collapse-toggle'); - this.headerContainerEl = this.el.select('.roo-card-header-ctr').first(); + this.footerEl = this.el.select('.card-footer',true).first(); + this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first(); + this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first(); this.headerEl = this.el.select('.card-header',true).first(); if (this.rotated) { this.el.addClass('roo-card-rotated'); this.fireEvent('rotate', this, true); } + this.header_imageEl = this.el.select('.card-img-top',true).first(); + this.header_imageEl.on('load', this.onHeaderImageLoad, this ); }, getDragData : function(e) @@ -2369,6 +2414,17 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { /** * Part of the Roo.dd.DropZone interface. If no target node is found, the * whole Element becomes the target, and this causes the drop gesture to append. + * + * Returns an object: + * { + + position : 'below' or 'above' + card : relateive to card OBJECT (or true for no cards listed) + items_n : relative to nth item in list + card_n : relative to nth card in list + } + * + * */ getTargetFromEvent : function(e, dragged_card_el) { @@ -2462,7 +2518,11 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } Roo.log(['getTargetFromEvent', target_info ]); - + + if (this.fireEvent('cardover', this, [ data ]) === false) { + return false; + } + this.dropPlaceHolder('show', target_info,data); return false; @@ -2487,9 +2547,7 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { } this.dropPlaceHolder('hide'); - - - + this.acceptCard(data.source, info.position, info.card, info.items_n); return true; @@ -2679,7 +2737,31 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { }, setHeaderText: function(html) { - this.headerContainerEl.dom.innerHTML = html; + this.header = html; + if (this.headerContainerEl) { + this.headerContainerEl.dom.innerHTML = html; + } + }, + onHeaderImageLoad : function(ev, he) + { + if (!this.header_image_fit_square) { + return; + } + + var hw = he.naturalHeight / he.naturalWidth; + // wide image = < 0 + // tall image = > 1 + //var w = he.dom.naturalWidth; + var ww = he.width; + he.style.left = 0; + he.style.position = 'relative'; + if (hw > 1) { + var nw = (ww * (1/hw)); + Roo.get(he).setSize( ww * (1/hw), ww); + he.style.left = ((ww - nw)/ 2) + 'px'; + he.style.position = 'relative'; + } + } @@ -2695,6 +2777,8 @@ Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, { /** * @class Roo.bootstrap.CardHeader * @extends Roo.bootstrap.Element + * @parent Roo.bootstrap.Card + * @children Roo.bootstrap.Component * Bootstrap CardHeader class * @constructor * Create a new Card Header - that you can embed children into @@ -2728,7 +2812,10 @@ Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, { /** * @class Roo.bootstrap.CardFooter * @extends Roo.bootstrap.Element + * @parent Roo.bootstrap.Card + * @children Roo.bootstrap.Component * Bootstrap CardFooter class + * * @constructor * Create a new Card Footer - that you can embed children into * @param {Object} config The config object @@ -2761,7 +2848,10 @@ Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, { /** * @class Roo.bootstrap.CardImageTop * @extends Roo.bootstrap.Element + * @parent Roo.bootstrap.Card + * @children Roo.bootstrap.Component * Bootstrap CardImageTop class + * * @constructor * Create a new Card Image Top container * @param {Object} config The config object @@ -2783,6 +2873,172 @@ Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, { + +/* +* Licence: LGPL +*/ + +/** + * @class Roo.bootstrap.ButtonUploader + * @extends Roo.bootstrap.Button + * Bootstrap Button Uploader class - it's a button which when you add files to it + * + * + * @cfg {Number} errorTimeout default 3000 + * @cfg {Array} images an array of ?? Img objects ??? when loading existing files.. + * @cfg {Array} html The button text. + * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded. + * + * @constructor + * Create a new CardUploader + * @param {Object} config The config object + */ + +Roo.bootstrap.ButtonUploader = function(config){ + + + + Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config); + + + this.addEvents({ + // raw events + /** + * @event beforeselect + * When button is pressed, before show upload files dialog is shown + * @param {Roo.bootstrap.UploaderButton} this + * + */ + 'beforeselect' : true, + /** + * @event fired when files have been selected, + * When a the download link is clicked + * @param {Roo.bootstrap.UploaderButton} this + * @param {Array} Array of files that have been uploaded + */ + 'uploaded' : true + + }); +}; + +Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, { + + + errorTimeout : 3000, + + images : false, + + fileCollection : false, + allowBlank : true, + + multiple : true, + + getAutoCreate : function() + { + + + return { + cls :'div' , + cn : [ + Roo.bootstrap.Button.prototype.getAutoCreate.call(this) + ] + }; + + + }, + + + initEvents : function() + { + + Roo.bootstrap.Button.prototype.initEvents.call(this); + + + + + + this.urlAPI = (window.createObjectURL && window) || + (window.URL && URL.revokeObjectURL && URL) || + (window.webkitURL && webkitURL); + + var im = { + tag: 'input', + type : 'file', + cls : 'd-none roo-card-upload-selector' + + }; + if (this.multiple) { + im.multiple = 'multiple'; + } + this.selectorEl = Roo.get(document.body).createChild(im); // so it does not capture click event for navitem. + + //this.selectorEl = this.el.select('.roo-card-upload-selector', true).first(); + + this.selectorEl.on('change', this.onFileSelected, this); + + + + }, + + + onClick : function(e) + { + e.preventDefault(); + + if ( this.fireEvent('beforeselect', this) === false) { + return; + } + + this.selectorEl.dom.click(); + + }, + + onFileSelected : function(e) + { + e.preventDefault(); + + if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){ + return; + } + var files = Array.prototype.slice.call(this.selectorEl.dom.files); + this.selectorEl.dom.value = '';// hopefully reset.. + + this.fireEvent('uploaded', this, files ); + + }, + + + + + /** + * addCard - add an Attachment to the uploader + * @param data - the data about the image to upload + * + * { + id : 123 + title : "Title of file", + is_uploaded : false, + src : "http://.....", + srcfile : { the File upload object }, + mimetype : file.type, + preview : false, + is_deleted : 0 + .. any other data... + } + * + * + */ + + reset: function() + { + + this.selectorEl + } + + + + +}); /* * - LGPL * @@ -2805,6 +3061,7 @@ Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, { * @cfg {String} smUrl sm image source * @cfg {String} mdUrl md image source * @cfg {String} lgUrl lg image source + * @cfg {Boolean} backgroundContain (use style background and contain image in content) * * @constructor * Create a new Input @@ -2821,7 +3078,13 @@ Roo.bootstrap.Img = function(config){ * The img click event for the img. * @param {Roo.EventObject} e */ - "click" : true + "click" : true, + /** + * @event load + * The when any image loads + * @param {Roo.EventObject} e + */ + "load" : true }); }; @@ -2836,6 +3099,7 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { smUrl: '', mdUrl: '', lgUrl: '', + backgroundContain : false, getAutoCreate : function() { @@ -2908,12 +3172,20 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { tag: 'img', cls: (this.imgResponsive) ? 'img-responsive' : '', html : null, - src : 'about:blank' // just incase src get's set to undefined?!? + src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!? }; + if (this.backgroundContain) { + cfg.cls += ' background-contain'; + } + cfg.html = this.html || cfg.html; - cfg.src = this.src || cfg.src; + if (this.backgroundContain) { + cfg.style="background-image: url(" + this.src + ')'; + } else { + cfg.src = this.src || cfg.src; + } if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) { cfg.cls += ' img-' + this.border; @@ -2946,6 +3218,12 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { if(!this.href){ this.el.on('click', this.onClick, this); } + if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){ + this.el.on('load', this.onImageLoad, this); + } else { + // not sure if this works.. not tested + this.el.select('img', true).on('load', this.onImageLoad, this); + } }, @@ -2954,6 +3232,12 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { Roo.log('img onclick'); this.fireEvent('click', this, e); }, + onImageLoad: function(e) + { + Roo.log('img load'); + this.fireEvent('load', this, e); + }, + /** * Sets the url of the image - used to update it * @param {String} url the url of the image @@ -2964,7 +3248,11 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { this.src = url; if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){ - this.el.dom.src = url; + if (this.backgroundContain) { + this.el.dom.style.backgroundImage = 'url(' + url + ')'; + } else { + this.el.dom.src = url; + } return; } @@ -2986,7 +3274,9 @@ Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, { /** * @class Roo.bootstrap.Link * @extends Roo.bootstrap.Component - * Bootstrap Link Class + * @children Roo.bootstrap.Component + * Bootstrap Link Class (eg. '') + * @cfg {String} alt image alternative text * @cfg {String} href a tag href * @cfg {String} target (_self|_blank|_parent|_top) target for a href. @@ -3090,7 +3380,10 @@ Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, { /** * @class Roo.bootstrap.Header * @extends Roo.bootstrap.Component + * @children Roo.bootstrap.Component * Bootstrap Header class + * + * * @cfg {String} html content of header * @cfg {Number} level (1|2|3|4|5|6) default 1 * @@ -3128,23 +3421,13 @@ Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, { - /* - * Based on: - * Ext JS Library 1.1.1 - * Copyright(c) 2006-2007, Ext JS, LLC. - * - * Originally Released Under LGPL - original licence link has changed is not relivant. - * - * Fork - LGPL - *