Changeset 1963045
- Timestamp:
- 10/25/2018 05:32:14 PM (7 years ago)
- Location:
- lightweight-loading-bar/trunk
- Files:
-
- 2 edited
-
lw-loading-bar.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lightweight-loading-bar/trunk/lw-loading-bar.php
r1962329 r1963045 10 10 defined('ABSPATH') or die('Access Denied'); 11 11 /* 12 _____ _ _ _ 13 |_ _| | | | | (_) 14 | | _ __ ___ | |_ _ __ _ _ ___ | |_ _ ___ _ __ ___ 12 _____ _ _ _ 13 |_ _| | | | | (_) 14 | | _ __ ___ | |_ _ __ _ _ ___ | |_ _ ___ _ __ ___ 15 15 | | | '_ \ / __| | __| | '__| | | | | / __| | __| | | / _ \ | '_ \ / __| 16 16 _| |_ | | | | \__ \ | |_ | | | |_| | | (__ | |_ | | | (_) | | | | | \__ \ 17 17 |_____| |_| |_| |___/ \__| |_| \__,_| \___| \__| |_| \___/ |_| |_| |___/ 18 18 19 19 If you want to enable gradient, set the gradient value to true, otherwise false. 20 20 If gradient is set to false the color value is what you need to set. 21 You can also customize the height. 21 You can customize the height of the loading bar. 22 You can change the position of the loading bar. 22 23 */ 23 24 … … 36 37 // Set height of the loading bar (ex. 5px or 10px). 5px by default. 37 38 $height = '5px'; 39 40 // Set the position of the loading bar (top = top, bottom = bottom). Top by default. 41 $position = 'top'; 38 42 39 43 //================================================================================ … … 54 58 } 55 59 60 if ($position == 'top' Xor $position == 'bottom') { 61 $lw_lb_position = $position; 62 } else { 63 $lw_lb_position = 'top'; 64 } 65 56 66 function lw_loading_bar_inject_element() { 57 67 ?> 58 68 <script type="text/javascript"> 59 (function(root){"use strict";var css=".lwloadingbar{width:100%;height:<?php global $lw_lb_height; echo $lw_lb_height ?>;z-index:9999; top:0}.bar{width:0;height:100%;transition:height .3s;background:<?php global $lw_lb_style; echo "$lw_lb_style" ?>}";function addCss(){var s=document.getElementById("lwloadingbarcss");if(s===null){s=document.createElement("style");s.type="text/css";s.id="lwloadingbarcss";document.head.insertBefore(s,document.head.firstChild);if(!s.styleSheet)return s.appendChild(document.createTextNode(css));s.styleSheet.cssText=css}}function addClass(el,cls){if(el.classList)el.classList.add(cls);else el.className+=" "+cls}function createBar(rm){var el=document.createElement("div"),width=0,here=0,on=0,bar={el:el,go:go};addClass(el,"bar");function move(){var dist=width-here;if(dist<.1&&dist>-.1){place(here);on=0;if(width>=100){el.style.height=0;setTimeout(function(){rm(el)},300)}}else{place(width-dist/4);setTimeout(go,16)}}function place(num){width=num;el.style.width=width+"%"}function go(num){if(num>=0){here=num;if(!on){on=1;move()}}else if(on){move()}}return bar}function LWLoadingbar(opts){opts=opts||{};var el=document.createElement("div"),applyGo,lwloadingbar={el:el,go:function(p){applyGo(p);if(p>=100){init()}}};function rm(child){el.removeChild(child)}function init(){var bar=createBar(rm);el.appendChild(bar.el);applyGo=bar.go}addCss();addClass(el,"lwloadingbar");if(opts.id)el.id=opts.id;if(opts.classname)addClass(el,opts.classname);if(opts.target){el.style.position="relative";opts.target.insertBefore(el,opts.target.firstChild)}else{el.style.position="fixed";document.getElementsByTagName("body")[0].appendChild(el)}init();return lwloadingbar}if(typeof exports==="object"){module.exports=LWLoadingbar}else if(typeof define==="function"&&define.amd){define([],function(){return LWLoadingbar})}else{root.LWLoadingbar=LWLoadingbar}})(this);69 (function(root){"use strict";var css=".lwloadingbar{width:100%;height:<?php global $lw_lb_height; echo $lw_lb_height ?>;z-index:9999;<?php global $lw_lb_position; echo $lw_lb_position ?>:0}.bar{width:0;height:100%;transition:height .3s;background:<?php global $lw_lb_style; echo "$lw_lb_style" ?>}";function addCss(){var s=document.getElementById("lwloadingbarcss");if(s===null){s=document.createElement("style");s.type="text/css";s.id="lwloadingbarcss";document.head.insertBefore(s,document.head.firstChild);if(!s.styleSheet)return s.appendChild(document.createTextNode(css));s.styleSheet.cssText=css}}function addClass(el,cls){if(el.classList)el.classList.add(cls);else el.className+=" "+cls}function createBar(rm){var el=document.createElement("div"),width=0,here=0,on=0,bar={el:el,go:go};addClass(el,"bar");function move(){var dist=width-here;if(dist<.1&&dist>-.1){place(here);on=0;if(width>=100){el.style.height=0;setTimeout(function(){rm(el)},300)}}else{place(width-dist/4);setTimeout(go,16)}}function place(num){width=num;el.style.width=width+"%"}function go(num){if(num>=0){here=num;if(!on){on=1;move()}}else if(on){move()}}return bar}function LWLoadingbar(opts){opts=opts||{};var el=document.createElement("div"),applyGo,lwloadingbar={el:el,go:function(p){applyGo(p);if(p>=100){init()}}};function rm(child){el.removeChild(child)}function init(){var bar=createBar(rm);el.appendChild(bar.el);applyGo=bar.go}addCss();addClass(el,"lwloadingbar");if(opts.id)el.id=opts.id;if(opts.classname)addClass(el,opts.classname);if(opts.target){el.style.position="relative";opts.target.insertBefore(el,opts.target.firstChild)}else{el.style.position="fixed";document.getElementsByTagName("body")[0].appendChild(el)}init();return lwloadingbar}if(typeof exports==="object"){module.exports=LWLoadingbar}else if(typeof define==="function"&&define.amd){define([],function(){return LWLoadingbar})}else{root.LWLoadingbar=LWLoadingbar}})(this); 60 70 </script> 61 71 62 72 <script type="text/javascript"> 63 73 var options = { id: 'lw-loading-bar' };var lwloadingbar = new LWLoadingbar( options );lwloadingbar.go(100); -
lightweight-loading-bar/trunk/readme.txt
r1962438 r1963045 14 14 ### Lightweight Loading Bar 15 15 16 Add a YouTube-style loading bar to your website easily! Extremely lightweight plugin that only adds 810 bytes to your page size. It also does not add anything to your database. Change color and height of bar from code easily in.16 Add a YouTube-style loading bar to your website easily! Extremely lightweight plugin that only adds 810 bytes to your page size. It also does not add anything to your database. Change color, height and all options of the loading bar from code easily. 17 17 18 18 ### Features … … 21 21 * Fully customizable static color. 22 22 * Option to use gradient. 23 * Set the position of the bar to either top or bottom. 23 24 * Customize loading bar color and height. 24 25 * Responsive and Retina ready. … … 42 43 43 44 * Inital Release. 45 46 = 1.1 = 47 48 * Added option to set position of the loading bar (top or bottom).
Note: See TracChangeset
for help on using the changeset viewer.