├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── build ├── dist ├── index.css ├── index.js ├── index.min.css ├── index.min.js ├── index.pug ├── ldcv.effects.css └── ldcv.effects.min.css ├── package-lock.json ├── package.json ├── src ├── ldcv.effects.styl ├── ldcv.ls ├── ldcv.pug └── ldcv.styl └── web ├── src ├── ls │ ├── alert │ │ ├── icon.ls │ │ └── index.ls │ └── index.ls ├── pug │ ├── alert │ │ └── index.pug │ ├── index.pug │ └── tos.pug └── styl │ ├── alert │ └── index.styl │ └── index.styl └── static ├── alert └── index.html ├── assets └── img │ ├── a │ ├── error.svg │ ├── info.svg │ ├── question.svg │ ├── success.svg │ ├── warning.svg │ └── x │ │ └── error.svg │ └── s │ ├── error.svg │ ├── info.svg │ ├── question.svg │ ├── success.svg │ └── warning.svg ├── css ├── alert │ ├── index.css │ └── index.min.css ├── index.css └── index.min.css ├── favicon.ico ├── index.html └── js ├── alert ├── icon.js ├── icon.min.js ├── index.js └── index.min.js ├── index.js └── index.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | .swp 3 | *.log 4 | secret.* 5 | node_modules 6 | web/.view 7 | web/static/assets/lib 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Logs 2 | 3 | ## v3.5.6 4 | 5 | - use `auto` instead of `scroll` in `.scroll` class to prevent scroll bar if scrolling is not necessary. 6 | 7 | 8 | ## v3.5.5 9 | 10 | - add `outer-gap` and `nested-gap` classes for more control about cover gapping 11 | 12 | 13 | ## v3.5.4 14 | 15 | - support DOM removal by `removeNode` option in `destroyer` API. 16 | 17 | 18 | ## v3.5.3 19 | 20 | - tweak style about gapping with `scroll` + `autogap` settings. 21 | 22 | 23 | ## v3.5.2 24 | 25 | - add `autogap` class for automatically prepare padding / gapping between window boundary 26 | 27 | 28 | ## v3.5.1 29 | 30 | - tweak fullscreen classes responsive settings 31 | 32 | 33 | ## v3.5.0 34 | 35 | - support conditional fullscreen class 36 | 37 | 38 | ## v3.4.0 39 | 40 | - support destroy function 41 | - remove escape listener once dialog is dismissed 42 | - clear inline cover click event listener variable once dismiss 43 | - fix bug: small gap in the left hand side due to :after pseudo class margin 44 | 45 | 46 | ## v3.3.1 47 | 48 | - fix bug: nested `data-ldcv-*` in child ldcover should not be propagated to parent ldcover. 49 | - upgrade modules to fix dependencies vulnerability 50 | 51 | 52 | ## v3.3.0 53 | 54 | - add `toggled.on` and `toggled.off` event for post toggle event 55 | 56 | 57 | ## v3.2.1 58 | 59 | - fix bug: when toggling off, z-index is updated too early, lead to unsmooth fading animaion sometimes. 60 | 61 | 62 | ## v3.2.0 63 | 64 | - add `data` parameter in `toggle` and `get` api for passing data between caller / callee. 65 | - add `data` event to pass data to callee 66 | 67 | 68 | ## v3.1.0 69 | 70 | - upgrade modules to fix dependencies vulnerability 71 | - add `inPlace` mode to decide if DOM should be re-added under body. 72 | 73 | 74 | ## v3.0.1 75 | 76 | - remove unnecessary `fs-extra` dependency 77 | 78 | 79 | ## v3.0.0 80 | 81 | - release with compact directory structure 82 | 83 | 84 | ## v2.1.2 85 | 86 | - add `style` field in `package.json` 87 | 88 | 89 | ## v2.1.1 90 | 91 | - use minimized dist file as main / browser default file 92 | - upgrade modules 93 | 94 | 95 | ## v2.1.0 96 | 97 | - support initializing DOM based on `template` tag for shadow DOM. 98 | - only insert DOM when cover is active. behavior controlled by `resident` option. 99 | - mangle + compress minimized js to optimize its size in advance. 100 | - lazy initializing until toggling if `root` is a template. 101 | - update document for undocumented features 102 | - member `root` is now a function for accessing `_r` (formal `root`) 103 | - support `inline` mode 104 | - modal displayed inline yet not affect layout 105 | - dismiss on clicking outside dialog 106 | 107 | 108 | ## v2.0.0 109 | 110 | - support `zmgr` directly in ldcover constructor 111 | - use zmgr fallback instead of zstack implementation to simplify code logic 112 | - remove legacy `ldCover` definition 113 | - update window object only if module is not available 114 | - rename `ldcv.*` to `index.*` 115 | - rename static method `set-zmgr` to `zmgr` 116 | - support multiple event syntax 117 | 118 | 119 | ## v1.3.3 120 | 121 | - add `cancel` api for canceling `get` call by promise rejection. 122 | - add `data-ldcv-cancel` directive corresponding to `cancel` api. 123 | 124 | 125 | ## v1.3.2 126 | 127 | - upgrade modules 128 | - add `ldcover` and deprecate `ldCover` 129 | 130 | 131 | ## v1.3.1 132 | 133 | - bug fix: move transition to `.running, .active` classes so there won't be a initial flash of dialog content. 134 | 135 | 136 | ## v1.3.0 137 | 138 | - add `setZmgr` for managing z-index globally. 139 | - update demo for testing `setZmgr`. 140 | 141 | 142 | ## v1.2.0 143 | 144 | - upgrade `template` and `livescript` 145 | - add `bootstrap.ldui` for development. 146 | - add `ldview` and `ldquery` for development. 147 | - tweak build script 148 | - refactor web/ 149 | - add `mini` style ldcover. 150 | 151 | 152 | ## v1.1.1 153 | 154 | - fix bug: escape should not close all modals, but only the topmost modal. 155 | - as a side effect we add an ldcv list ( `popup` ) in ldCover object to track popup order. 156 | 157 | 158 | ## v1.1.0 159 | 160 | - add lock function 161 | - fix bug: incorrect z-index calculation for nested cover 162 | - change scrolling behavior - default no scrolling 163 | - add demo site code 164 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2025 zbryikt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ldcover 2 | 3 | vanilla popup / dialog library. 4 | 5 | 6 | ## Usage 7 | 8 | install with npm: 9 | 10 | npm install ldcover 11 | 12 | include required files ( `index.js` and `index.css` ), and create a ldcover object: 13 | 14 | var ldcv = new ldcover({ ... }); 15 | 16 | 17 | ## Constructor Options 18 | 19 | - `root`: container. 20 | - you can use `template` tag as root for better performance during initialization. The first child in the template will be used as the real root for this ldcover. 21 | - `type`: additional class to add. default: ''. space seprated. 22 | - `transform-fix`: true/false. default: false. 23 | add a 'shown' class after ldcover is shown, which removes transform from .inner block. 24 | useful when content is blurred due to transform, but might lead to glitches when doing transition. use it carefully. 25 | - `delay`: milliseconds. default 300. should be aligned with transition duration. use to control 'shown' and 'running' classes. 26 | - `autoZ`: update root's z-index automatically. default true. 27 | - `baseZ`: the minimal z-index of root. default 3000. 28 | - with autoZ, ldcover keeps track of all cover' z-index and always use larger z-index for newly toggled covers. 29 | baseZ is then used as a base value for all autoZ covers. 30 | however, this may conflict with customized zmgr. 31 | - `zmgr`: set z-index manager for this cover. 32 | - `baseZ` will be used to call zmgr, which set a lower bound of `z-index`. 33 | set `baseZ` to 0 for zmgr to correct work with lower values. 34 | - `animation`: optional space separated class list. 35 | - will be added to .inner node when toggling on, and removed when toggling off. 36 | - handy for adding customized animation from libraries like transition.css or animate.css. 37 | - `escape`: should pressing escape key close the dialog. boolean, default true, optional. 38 | - `lock`: default false. if set to true, only API or data-ldcv-set could close this modal. 39 | - `resident`: default false. if set to true, DOM for this cover will always attached under document. otherwise false. 40 | - not resident node will be attached under `container` or document.body. 41 | - `inPlace`: default true. if set to false, root will be removed from original parent and re-added under body. 42 | - `container`: container for non-resident cover. by default parent of DOM or document.body 43 | - by default, non-resident cover is inserted to the location we find it. Set `container` to change this behavior. 44 | - when `container` is null, `root` is appended at the end of `document.body` when toggled. 45 | - otherwise, `root`is appended at the end of `container` when toggled. 46 | 47 | 48 | ## Object Methods 49 | 50 | - `toggle(state, data)`: toggle on/off ldcover. 51 | - `data`: optional parameter, which will be sent in `data` event. 52 | - program that manages the content of this cover can use this data to update its content. 53 | - `get(data)`: toggle on ldcover and return a promise, which will only be resolved when ldcover.set is called. 54 | - `data`: see `toggle` above. 55 | - `set(v, hide=true)`: set value, which resolve promises from get, and hide ldcover if hide = true. 56 | - use `data-ldcv-set` on elements to automatically set value when elements are clicked. 57 | - `cancel(err, hide=true)`: reject promise returned by `get` with given error `err`. 58 | - a default `Error` object with `{name: 'lderror', id: 999}` will be used if `err` is omitted. 59 | - ldcover is hidden if `hide` = true. true by default. 60 | - use `data-ldcv-cancel` on elements to automatically cancel when clicked. 61 | - `on(event, cb)`: listen to certain event. evnets: 62 | - `toggle.on`: when ldcover is toggled on. may fired before shown. 63 | - `toggle.off`: when ldcover is toggled off. may fired before hidden. 64 | - `toggled.on`: when ldcover is toggled on. fired after shown. 65 | - `toggled.off`: when ldcover is toggled off. fired after hidden. 66 | - `isOn()`: is this modal active ( opened ). return true or false 67 | - `lock()`: lock this cover. ( can't be dismissed by escaping ) 68 | - alternatively, you can lock cover by adding `data-lock="true"` attribute to cover root. 69 | - `root()`: get cover root node. 70 | - `zmgr(mgr)`: set z-index manager for this cover. return the zmgr used if `mgr` is omitted. 71 | - `baseZ` will be used to call zmgr, which set a lower bound of `z-index`. 72 | set `baseZ` to 0 for zmgr to correct work with lower values. 73 | - `append(node)`: insert `node` in the base node of this cover. 74 | - useful if this ldcover is created without root. 75 | - `destroy(opt)`: object destroyer. `opt` is an option object with following fields: 76 | - `removeNode`: should ldcover remove DOM of this cover. default false 77 | - by default, DOM of this cover will be inserted back in DOM after this ldcover object been destroyed. 78 | - to also wipe out the DOM element, set `removeNode` to true. 79 | 80 | 81 | ## Class Method 82 | 83 | - `zmgr(zmgr)`: set a shared z-index manager. useful to manager widget z-index globally. 84 | this manager should provide following methods: 85 | - `add(baseVal, size)`: return actual added value. 86 | - baseVal: hint value for the z-index we'd like to use 87 | - size: hint size about how large the object we added is 88 | - `remove(val)`: remove val ( returned by add ) from this manager. 89 | 90 | as described above, `baseZ` will be used to call zmgr, which set a lower bound of `z-index`. 91 | set `baseZ` to 0 in ldcover instance so zmgr can work correclty with lower values. 92 | 93 | 94 | ## Spec. and structure 95 | 96 | A simple ldcover popup are built with following html structure: 97 | 98 | * .ldcv - topmost, fullscreen container 99 | * .base - control the overall size and position for this box ( could be omit ) 100 | * .inner - dialog container. constraint size. transition animation goes here 101 | 102 | 103 | one can decorate ldcover widgets by adding classes over the outmost element. following classes are defined by default: 104 | 105 | * .ldcv.bare: 106 | - no covered bk. 107 | - custom position for .ldcv > .base 108 | - overflow: visible for .ldcv > .base > .inner (why?) 109 | * .ldcv.lg, .ldcv.md 110 | - different size of panel. instead of using this, you could also set size directly on .base element. 111 | * .ldcv.full - fullscreen modal. 112 | * .ldcv.full-sm, .ldcv.full-md, .ldcv.full-lg - conditional fullscreen modal. break point: 113 | - `sm`: < 576px 114 | - `md`: < 768px 115 | - `lg`: < 960px 116 | * .ldcv.light - light overlay bk 117 | * .ldcv.mini - non-blocking, float style dialog with following position available: 118 | - .ldcv.mini.left 119 | - .ldcv.mini.right 120 | - .ldcv.mini.top 121 | - .ldcv.mini.bottom 122 | * .ldcv.inline - inline cover. Won't affect local layout 123 | 124 | * centering 125 | - by default .base is centered with vertical-align + ::after pseudo class. instead you can choose different methods, described below: 126 | - .ldcv.margin-centered 127 | - center with margin: auto + left/right/top/bottom: 0 and position: absolute. need width/height to be provided. 128 | - .ldcv.transform-centered 129 | - with transform-center, .base is centered with left: 50%, top: 50% + transform: translate(-50%,-50%), which don't need width/height to be provided anymore. 130 | - NOTE: this might causes content to be blur, so use it carefully. 131 | 132 | * .ldcv.scroll: 133 | - add `scroll` class on the ldcv node when you expect the modal content to longer than a screen's height. It makes the modal scrollable by users. 134 | 135 | * .ldcv.autogap: 136 | - add `autogap` class on the ldcv node to automatically adjust cover padding and margin along with responsive scenario, with two additional classes: 137 | - `.outer-gap`: only apply margin style. Used alone without `autogap` 138 | - `.autogap.nested-gap`: apply padding style in nested div. Used along with `autogap` 139 | 140 | * alternative transition 141 | - you can use alternative transition by adding additional class in .ldcv, including following classes: 142 | - ldcv-scale 143 | - ldcv-zoom 144 | - ldcv-vortex 145 | - ldcv-slide-rtl 146 | - ldcv-slide-ltr 147 | - ldcv-slide-ttb 148 | - ldcv-slide-btt 149 | - ldcv-flip-h-left 150 | - ldcv-flip-h-right 151 | - ldcv-flip-v-top 152 | - ldcv-flip-v-bottom 153 | - ldcv-fade 154 | - example of setting a alternative transition: 155 | 156 | 157 |
you clicked the button.
this is a popup that will be triggered after you open this website.
this is a hint with normal priority, which has the same priority with the timeout popup.
This modal is created based on a template tag as root. Since browser only parses but not renders tags inside template, this can effectively reduce DOM element count, thus improve performance.
We have saved your confirmation. You won't see this again until next time we update our terms and conditions.
resolving get
call by data-ldcv-set
or set
api call.
rejecting get
call by data-ldcv-cancel
or cancel
api call
Last updated: December 21, 2020
Please read these terms and conditions carefully before using Our Service.
The words of which the initial letter is capitalized have meanings defined under the following conditions. The following definitions shall have the same meaning regardless of whether they appear in singular or in plural.
For the purposes of these Terms and Conditions:
Affiliate means an entity that controls, is controlled by or is under common control with a party, where "control" means ownership of 50% or more of the shares, equity interest or other securities entitled to vote for election of directors or other managing authority.
Country refers to: Taiwan
Company (referred to as either "the Company", "We", "Us" or "Our" in this Agreement) refers to sample.
Device means any device that can access the Service such as a computer, a cellphone or a digital tablet.
Service refers to the Website.
Terms and Conditions (also referred as "Terms") mean these Terms and Conditions that form the entire agreement between You and the Company regarding the use of the Service. This Terms and Conditions agreement has been created with the help of the Terms and Conditions Generator.
Third-party Social Media Service means any services or content (including data, information, products or services) provided by a third-party that may be displayed, included or made available by the Service.
Website refers to sample, accessible from https://loading.io/lib/modal
You means the individual accessing or using the Service, or the company, or other legal entity on behalf of which such individual is accessing or using the Service, as applicable.
These are the Terms and Conditions governing the use of this Service and the agreement that operates between You and the Company. These Terms and Conditions set out the rights and obligations of all users regarding the use of the Service.
Your access to and use of the Service is conditioned on Your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all visitors, users and others who access or use the Service.
By accessing or using the Service You agree to be bound by these Terms and Conditions. If You disagree with any part of these Terms and Conditions then You may not access the Service.
You represent that you are over the age of 18. The Company does not permit those under 18 to use the Service.
Your access to and use of the Service is also conditioned on Your acceptance of and compliance with the Privacy Policy of the Company. Our Privacy Policy describes Our policies and procedures on the collection, use and disclosure of Your personal information when You use the Application or the Website and tells You about Your privacy rights and how the law protects You. Please read Our Privacy Policy carefully before using Our Service.
Our Service may contain links to third-party web sites or services that are not owned or controlled by the Company.
The Company has no control over, and assumes no responsibility for, the content, privacy policies, or practices of any third party web sites or services. You further acknowledge and agree that the Company shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with the use of or reliance on any such content, goods or services available on or through any such web sites or services.
We strongly advise You to read the terms and conditions and privacy policies of any third-party web sites or services that You visit.
We may terminate or suspend Your access immediately, without prior notice or liability, for any reason whatsoever, including without limitation if You breach these Terms and Conditions.
Upon termination, Your right to use the Service will cease immediately.
Notwithstanding any damages that You might incur, the entire liability of the Company and any of its suppliers under any provision of this Terms and Your exclusive remedy for all of the foregoing shall be limited to the amount actually paid by You through the Service or 100 USD if You haven't purchased anything through the Service.
To the maximum extent permitted by applicable law, in no event shall the Company or its suppliers be liable for any special, incidental, indirect, or consequential damages whatsoever (including, but not limited to, damages for loss of profits, loss of data or other information, for business interruption, for personal injury, loss of privacy arising out of or in any way related to the use of or inability to use the Service, third-party software and/or third-party hardware used with the Service, or otherwise in connection with any provision of this Terms), even if the Company or any supplier has been advised of the possibility of such damages and even if the remedy fails of its essential purpose.
Some states do not allow the exclusion of implied warranties or limitation of liability for incidental or consequential damages, which means that some of the above limitations may not apply. In these states, each party's liability will be limited to the greatest extent permitted by law.
The Service is provided to You "AS IS" and "AS AVAILABLE" and with all faults and defects without warranty of any kind. To the maximum extent permitted under applicable law, the Company, on its own behalf and on behalf of its Affiliates and its and their respective licensors and service providers, expressly disclaims all warranties, whether express, implied, statutory or otherwise, with respect to the Service, including all implied warranties of merchantability, fitness for a particular purpose, title and non-infringement, and warranties that may arise out of course of dealing, course of performance, usage or trade practice. Without limitation to the foregoing, the Company provides no warranty or undertaking, and makes no representation of any kind that the Service will meet Your requirements, achieve any intended results, be compatible or work with any other software, applications, systems or services, operate without interruption, meet any performance or reliability standards or be error free or that any errors or defects can or will be corrected.
Without limiting the foregoing, neither the Company nor any of the company's provider makes any representation or warranty of any kind, express or implied: (i) as to the operation or availability of the Service, or the information, content, and materials or products included thereon; (ii) that the Service will be uninterrupted or error-free; (iii) as to the accuracy, reliability, or currency of any information or content provided through the Service; or (iv) that the Service, its servers, the content, or e-mails sent from or on behalf of the Company are free of viruses, scripts, trojan horses, worms, malware, timebombs or other harmful components.
Some jurisdictions do not allow the exclusion of certain types of warranties or limitations on applicable statutory rights of a consumer, so some or all of the above exclusions and limitations may not apply to You. But in such a case the exclusions and limitations set forth in this section shall be applied to the greatest extent enforceable under applicable law.
The laws of the Country, excluding its conflicts of law rules, shall govern this Terms and Your use of the Service. Your use of the Application may also be subject to other local, state, national, or international laws.
If You have any concern or dispute about the Service, You agree to first try to resolve the dispute informally by contacting the Company.
If You are a European Union consumer, you will benefit from any mandatory provisions of the law of the country in which you are resident in.
You represent and warrant that (i) You are not located in a country that is subject to the United States government embargo, or that has been designated by the United States government as a "terrorist supporting" country, and (ii) You are not listed on any United States government list of prohibited or restricted parties.
If any provision of these Terms is held to be unenforceable or invalid, such provision will be changed and interpreted to accomplish the objectives of such provision to the greatest extent possible under applicable law and the remaining provisions will continue in full force and effect.
Except as provided herein, the failure to exercise a right or to require performance of an obligation under this Terms shall not effect a party's ability to exercise such right or require such performance at any time thereafter nor shall be the waiver of a breach constitute a waiver of any subsequent breach.
These Terms and Conditions may have been translated if We have made them available to You on our Service. 4 | You agree that the original English text shall prevail in the case of a dispute.
We reserve the right, at Our sole discretion, to modify or replace these Terms at any time. If a revision is material We will make reasonable efforts to provide at least 30 days' notice prior to any new terms taking effect. What constitutes a material change will be determined at Our sole discretion.
By continuing to access or use Our Service after those revisions become effective, You agree to be bound by the revised terms. If You do not agree to the new terms, in whole or in part, please stop using the website and the Service.
If you have any questions about these Terms and Conditions, You can contact us: