Selaa lähdekoodia

New data-attribute "loading" and new method element.loading()

@soyjavi 14 vuotta sitten
vanhempi
commit
db660eda58

+ 5 - 0
examples/test/app/events.js

@@ -6,7 +6,12 @@ App.Events = (function(lng, undefined) {
 
             lng.View.Element.progress('#progress-normal', 50, true, 'yeah');
             lng.View.Element.progress('#progress-big', 75, true, 'yeah');
+
+            lng.View.Element.loading('#loading-code', 'white');
         }, 1000);
+
+
+
     });
 
     //SPECIAL

+ 3 - 3
examples/test/index.html

@@ -31,14 +31,13 @@
     <link rel="stylesheet" href="../../src/stylesheets/css/Lungo.widgets.form.css">
     <link rel="stylesheet" href="../../src/stylesheets/css/Lungo.widgets.colour.css">
     <link rel="stylesheet" href="../../src/stylesheets/css/Lungo.widgets.icon.css">
+    <link rel="stylesheet" href="../../src/stylesheets/css/Lungo.widgets.loading.css">
     <link rel="stylesheet" href="../../src/stylesheets/css/Lungo.theme.default.css">
     <!-- App Stylesheet -->
     <link rel="stylesheet" href="assets/stylesheets/app.css">
 </head>
 
 <body class="app">
-
-
     <section id="test-1" class="pop">
         <header class="extended">
             <nav class="onleft">
@@ -53,7 +52,6 @@
             </nav>
         </header>
 
-
         <nav class="groupbar">
             <a href="#nav-1" data-target="article" class="current"  data-icon="clock">&nbsp;Alarm</a>
             <a href="#nav-2" data-target="article" data-icon="calendar">&nbsp;Calendar</a>
@@ -83,6 +81,8 @@
         <article id="nav-1" class="list indented scrollable">
 
             <ul class="form">
+                <li data-loading="black big"></li>
+                <li id="loading-code" style="background-color: grey;"></li>
                 <li>
                     <label>type="text"</label>
                     <input type="text" placeholder="Input text"/>

+ 10 - 0
src/attributes/Lungo.Attributes.Data.js

@@ -51,6 +51,16 @@ LUNGO.Attributes.Data = {
         selector: 'header, footer, article',
         html: '<span class="title centered">{{value}}</span>'
     },
+    Loading: {
+        tag: 'loading',
+        selector: '*',
+        html: '<div class="loading {{value}}">\
+                    <span class="top"></span>\
+                    <span class="right"></span>\
+                    <span class="bottom"></span>\
+                    <span class="left"></span>\
+                </div>'
+    },
     Back: {
         tag: 'back',
         selector: 'header, footer',

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/stylesheets/css/Lungo.widgets.loading.css


+ 13 - 12
src/stylesheets/less/Lungo.widgets.less

@@ -13,13 +13,13 @@
 /* @group scroll */
 
 .scrollable {
-	position: absolute;
-	display: block;
+  position: absolute;
+  display: block;
 }
 
 .scroll {
-  	overflow: scroll;
-  	-webkit-overflow-scrolling: touch;
+    overflow: scroll;
+    -webkit-overflow-scrolling: touch;
 }
 /* @end */
 
@@ -40,14 +40,14 @@
 
 /* @group .sizing */
 .size32 {
-	font-size: 32px;
+  font-size: 32px;
     height: 32px;
     width: 32px;
     line-height: 32px;
 }
 
 .icon.mini {
-	font-size: 20px !important;
+  font-size: 20px !important;
     height: 16px !important;
     width: 16px !important;
     line-height: 16px !important;
@@ -61,9 +61,10 @@
 /* @end */
 
 .bubble {
-	padding: 2px 3px 1px;
-	.border-radius(1px);
-	font-size: 0.8em;
-	font-weight: bold;
-	line-height: 1.0em;
-}
+  padding: 2px 3px 1px;
+  .border-radius(1px);
+  font-size: 0.8em;
+  font-weight: bold;
+  line-height: 1.0em;
+}
+

+ 116 - 0
src/stylesheets/less/Lungo.widgets.loading.less

@@ -0,0 +1,116 @@
+/**
+ * Stylesheet
+ *
+ * @namespace LUNGO.Widgets
+ * @class Loading
+ *
+ * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
+ */
+
+.loading {
+    position:relative;
+    left: 50%;
+    height: 1em;
+    width: 1em;
+    margin-left: -.5em;
+    -webkit-transform-origin: .5em .5em;
+    -webkit-animation:  rotatingLoader .5s  infinite  linear;
+
+    font-size: 48px;
+
+    &.small { font-size: 20px; }
+    &.big { font-size: 64px; }
+
+    & > span {
+        left:         50%;
+        margin-left:  -0.05em;
+
+
+        &, &::before, &::after {
+            display:                  block;
+            position:                 absolute;
+            width:                    .1em;
+            height:                   .25em;
+            top:                      0;
+            -webkit-transform-origin: .05em .5em;
+            border-radius:            .1em;
+        }
+
+        &::before, &::after{ content: " "; }
+
+
+        &.top{ -webkit-transform: rotate(0deg); }
+        &.right{ -webkit-transform: rotate(90deg); }
+        &.bottom{ -webkit-transform: rotate(180deg); }
+        &.left{ -webkit-transform: rotate(270deg); }
+
+        &::before{ -webkit-transform: rotate(30deg); }
+        &::after{ -webkit-transform: rotate(-30deg); }
+
+        &.top           {  background-color: rgba(0,0,0,0.99); }
+        &.top::after    {  background-color: rgba(0,0,0,0.90); }
+        &.left::before  {  background-color: rgba(0,0,0,0.80); }
+        &.left          {  background-color: rgba(0,0,0,0.70); }
+        &.left::after   {  background-color: rgba(0,0,0,0.60); }
+        &.bottom::before{  background-color: rgba(0,0,0,0.50); }
+        &.bottom        {  background-color: rgba(0,0,0,0.40); }
+        &.bottom::after {  background-color: rgba(0,0,0,0.35); }
+        &.right::before {  background-color: rgba(0,0,0,0.30); }
+        &.right         {  background-color: rgba(0,0,0,0.25); }
+        &.right::after  {  background-color: rgba(0,0,0,0.20); }
+        &.top::before   {  background-color: rgba(0,0,0,0.15); }
+    }
+
+    &.white > span {
+        &.top           {  background-color: rgba(255,255,255,0.99); }
+        &.top::after    {  background-color: rgba(255,255,255,0.90); }
+        &.left::before  {  background-color: rgba(255,255,255,0.80); }
+        &.left          {  background-color: rgba(255,255,255,0.70); }
+        &.left::after   {  background-color: rgba(255,255,255,0.60); }
+        &.bottom::before{  background-color: rgba(255,255,255,0.50); }
+        &.bottom        {  background-color: rgba(255,255,255,0.40); }
+        &.bottom::after {  background-color: rgba(255,255,255,0.35); }
+        &.right::before {  background-color: rgba(255,255,255,0.30); }
+        &.right         {  background-color: rgba(255,255,255,0.25); }
+        &.right::after  {  background-color: rgba(255,255,255,0.20); }
+        &.top::before   {  background-color: rgba(255,255,255,0.15); }
+    }
+}
+
+@-webkit-keyframes rotatingLoader{
+    0%{     -webkit-transform: rotate(0deg);   }
+    8.32%{  -webkit-transform: rotate(0deg);   }
+
+    8.33%{  -webkit-transform: rotate(30deg);  }
+    16.65%{ -webkit-transform: rotate(30deg);  }
+
+    16.66%{ -webkit-transform: rotate(60deg);  }
+    24.99%{ -webkit-transform: rotate(60deg);  }
+
+    25%{    -webkit-transform: rotate(90deg);  }
+    33.32%{ -webkit-transform: rotate(90deg);  }
+
+    33.33%{ -webkit-transform: rotate(120deg); }
+    41.65%{ -webkit-transform: rotate(120deg); }
+
+    41.66%{ -webkit-transform: rotate(150deg); }
+    49.99%{ -webkit-transform: rotate(150deg); }
+
+    50%{    -webkit-transform: rotate(180deg); }
+    58.32%{ -webkit-transform: rotate(180deg); }
+
+    58.33%{ -webkit-transform: rotate(210deg); }
+    66.65%{ -webkit-transform: rotate(210deg); }
+
+    66.66%{ -webkit-transform: rotate(240deg); }
+    74.99%{ -webkit-transform: rotate(240deg); }
+
+    75%{    -webkit-transform: rotate(270deg); }
+    83.32%{ -webkit-transform: rotate(270deg); }
+
+    83.33%{ -webkit-transform: rotate(300deg); }
+    91.65%{ -webkit-transform: rotate(300deg); }
+
+    91.66%{ -webkit-transform: rotate(330deg); }
+    100%{   -webkit-transform: rotate(330deg); }
+}

+ 26 - 5
src/view/Lungo.View.Element.js

@@ -58,6 +58,24 @@ LUNGO.View.Element = (function(lng, undefined) {
         }
     };
 
+    /**
+     * Set a progress to the element
+     *
+     * @method progress
+     *
+     * @param  {string}  Element query selector
+     * @param  {number}  Percentage
+     * @param  {boolean} Show the labels: description and current percentage
+     * @param  {string}  Description
+     */
+    var loading = function(selector, stylesheet) {
+        var element = lng.dom(selector);
+
+        if (element) {
+            _bindAttribute(element, LUNGO.Attributes.Data.Loading, stylesheet);
+        }
+    };
+
     var _setBubble = function(element, count) {
         var bubbles = element.children(SELECTORS.BUBBLE);
         var total_bubbles = bubbles.length;
@@ -65,16 +83,19 @@ LUNGO.View.Element = (function(lng, undefined) {
         if (total_bubbles > 0) {
             bubbles.html(count);
         } else {
-            var count_html = LUNGO.Attributes.Data.Count.html;
-            var html_binded = count_html.replace(BINDING.START + BINDING.KEY + BINDING.END, count);
-
-            element.append(html_binded);
+            _bindAttribute(element, LUNGO.Attributes.Data.Count, count);
         }
     };
 
+    var _bindAttribute = function(element, attribute, data) {
+        var html_binded = attribute.html.replace(BINDING.START + BINDING.KEY + BINDING.END, data);
+        element.append(html_binded);
+    };
+
     return {
         count: count,
-        progress: progress
+        progress: progress,
+        loading: loading
     };
 
 })(LUNGO);

+ 1 - 1
vendor/build.sh

@@ -96,7 +96,7 @@ FILES_TO_COMPRESS=""
     DIR=$LUNGO_SOURCES"stylesheets/css/"
 
     echo -e "\033[33m  [DIR]: "$DIR
-    FILES=(base layout layout.nav layout.aside layout.article layout.list widgets widgets.splash widgets.button widgets.form widgets.colour )
+    FILES=(base layout layout.nav layout.aside layout.article layout.list widgets widgets.splash widgets.button widgets.form widgets.colour widget.loading )
     for file in "${FILES[@]}"
     do
         echo "    - Compressing "$DIR$LUNGO_NAMESPACE$file".css ..."