Kaynağa Gözat

Default theme: Improve compatibility with older browsers

Namely (it could hardly be different...) Internet Explorer - even IE11 still causes trouble. The default theme now supports IE9+, even older browsers will present broken markup. The sliding animation works with IE10+ (however, it is still usable, there's just no nice animation).

Furthermore this commit heavily improves the sliding process by allowing to abort the animation. I've updated Pico's screenshot in the , too.
Daniel Rudolf 9 yıl önce
ebeveyn
işleme
432710c400

+ 1 - 1
README.md

@@ -11,7 +11,7 @@ Pico is a stupidly simple, blazing fast, flat file CMS. See http://picocms.org/
 
 
 Screenshot
 Screenshot
 -------
 -------
-![Pico Screenshot](https://cloud.githubusercontent.com/assets/640217/11488596/70b39396-978d-11e5-885e-01341ad9dd75.gif)
+![Pico Screenshot](https://cloud.githubusercontent.com/assets/920356/17342119/f5a85ee8-58f7-11e6-856e-cd72f76cec61.png)
 
 
 Install
 Install
 -------
 -------

+ 1 - 0
themes/default/index.twig

@@ -62,6 +62,7 @@
         </div>
         </div>
     </footer>
     </footer>
 
 
+    <script src="{{ theme_url }}/js/modernizr-3.3.1-custom.min.js" type="text/javascript"></script>
     <script src="{{ theme_url }}/js/utils.js" type="text/javascript"></script>
     <script src="{{ theme_url }}/js/utils.js" type="text/javascript"></script>
     <script src="{{ theme_url }}/js/pico.js" type="text/javascript"></script>
     <script src="{{ theme_url }}/js/pico.js" type="text/javascript"></script>
 
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2 - 0
themes/default/js/modernizr-3.3.1-custom.min.js


+ 7 - 8
themes/default/js/pico.js

@@ -11,14 +11,13 @@
 
 
 function main() {
 function main() {
     // capability CSS classes
     // capability CSS classes
-    document.documentElement.classList.remove('no-js');
-    document.documentElement.classList.add('js');
+    document.documentElement.className = 'js';
 
 
     // wrap tables
     // wrap tables
     utils.forEach(document.querySelectorAll('main table'), function (_, table) {
     utils.forEach(document.querySelectorAll('main table'), function (_, table) {
-        if (!table.parentElement.classList.contains('table-responsive')) {
+        if (!/\btable-responsive\b/.test(table.parentElement.className)) {
             var tableWrapper = document.createElement('div');
             var tableWrapper = document.createElement('div');
-            tableWrapper.classList.add('table-responsive');
+            tableWrapper.className = 'table-responsive';
 
 
             table.parentElement.insertBefore(tableWrapper, table);
             table.parentElement.insertBefore(tableWrapper, table);
             tableWrapper.appendChild(table);
             tableWrapper.appendChild(table);
@@ -49,14 +48,14 @@ function main() {
         },
         },
         onResizeEvent = function () {
         onResizeEvent = function () {
             if (utils.isElementVisible(menuToggle)) {
             if (utils.isElementVisible(menuToggle)) {
-                menu.classList.add('hidden');
+                menu.className = 'hidden';
                 menuToggle.addEventListener('click', toggleMenuEvent);
                 menuToggle.addEventListener('click', toggleMenuEvent);
                 menuToggle.addEventListener('keydown', toggleMenuEvent);
                 menuToggle.addEventListener('keydown', toggleMenuEvent);
             } else {
             } else {
-                menuToggle.removeEventListener('keydown', toggleMenuEvent);
+                menu.className = '';
+                menu.removeAttribute('data-slide-id');
                 menuToggle.removeEventListener('click', toggleMenuEvent);
                 menuToggle.removeEventListener('click', toggleMenuEvent);
-                menu.classList.remove('hidden', 'slide', 'up');
-                delete menu.dataset.slideId;
+                menuToggle.removeEventListener('keydown', toggleMenuEvent);
             }
             }
         };
         };
 
 

+ 58 - 68
themes/default/js/utils.js

@@ -16,7 +16,8 @@ utils = {};
  *
  *
  * @param  object   object   the object to iterate through
  * @param  object   object   the object to iterate through
  * @param  function callback function to call on every item; the key is passed
  * @param  function callback function to call on every item; the key is passed
- *     as first, the value as second parameter
+ *     as first, the value as second parameter; the callback may return FALSE
+ *     to stop the iteration
  * @return void
  * @return void
  */
  */
 utils.forEach = function (object, callback) {
 utils.forEach = function (object, callback) {
@@ -31,76 +32,55 @@ utils.forEach = function (object, callback) {
 };
 };
 
 
 /**
 /**
- * Slides a element up (i.e. hide a element by changing its height to 0)
+ * Checks whether the client's browser is able to slide elements or not
  *
  *
- * @param  HTMLElement element        the element to slide up
- * @param  function    finishCallback function to call when the animation has
- *     been finished (i.e. the element is hidden)
- * @param  function    startCallback  function to call when the animation starts
- * @return void
+ * @return boolean TRUE when the browser supports sliding, FALSE otherwise
  */
  */
-utils.slideUp = function (element, finishCallback, startCallback) {
-    utils.slideOut(element, {
-        cssRule: 'height',
-        cssRuleRef: 'clientHeight',
-        cssClass: 'up',
-        startCallback: startCallback,
-        finishCallback: finishCallback
-    });
+utils.canSlide = function () {
+    return (Modernizr.classlist && Modernizr.requestanimationframe && Modernizr.csstransitions);
 };
 };
 
 
 /**
 /**
- * Slides a element down (i.e. show a hidden element)
+ * Slides a element up (i.e. hide a element by changing its height to 0px)
  *
  *
- * @param  HTMLElement element        the element to slide down
+ * @param  HTMLElement element        the element to slide up
  * @param  function    finishCallback function to call when the animation has
  * @param  function    finishCallback function to call when the animation has
- *     been finished (i.e. the element is visible)
+ *     been finished (i.e. the element is hidden)
  * @param  function    startCallback  function to call when the animation starts
  * @param  function    startCallback  function to call when the animation starts
  * @return void
  * @return void
  */
  */
-utils.slideDown = function (element, finishCallback, startCallback) {
-    utils.slideIn(element, {
-        cssRule: 'height',
-        cssRuleRef: 'clientHeight',
-        cssClass: 'up',
-        startCallback: startCallback,
-        finishCallback: finishCallback
-    });
-};
+utils.slideUp = function (element, finishCallback, startCallback) {
+    if (!utils.canSlide()) {
+        if (startCallback) startCallback();
+        element.className += (element.className !== '') ? ' hidden' : 'hidden';
+        if (finishCallback) window.requestAnimationFrame(finishCallback);
+        return;
+    }
 
 
-/**
- * Slides a element out (i.e. hide the element)
- *
- * @param  HTMLElement element the element to slide out
- * @param  object      options the settings of the sliding process
- * @return void
- */
-utils.slideOut = function (element, options) {
-    element.style[options.cssRule] = element[options.cssRuleRef] + 'px';
+    element.style.height = element.clientHeight + 'px';
 
 
-    var slideId = parseInt(element.dataset.slideId) || 0;
-    element.dataset.slideId = ++slideId;
+    var slideId = parseInt(element.getAttribute('data-slide-id')) || 0;
+    element.setAttribute('data-slide-id', ++slideId);
 
 
     window.requestAnimationFrame(function () {
     window.requestAnimationFrame(function () {
         element.classList.add('slide');
         element.classList.add('slide');
 
 
         window.requestAnimationFrame(function () {
         window.requestAnimationFrame(function () {
-            element.classList.add(options.cssClass);
+            element.style.height = '0px';
 
 
-            if (options.startCallback) {
-                options.startCallback();
+            if (startCallback) {
+                startCallback();
             }
             }
 
 
             window.setTimeout(function () {
             window.setTimeout(function () {
-                if (parseInt(element.dataset.slideId) !== slideId) return;
+                if (parseInt(element.getAttribute('data-slide-id')) !== slideId) return;
 
 
                 element.classList.add('hidden');
                 element.classList.add('hidden');
                 element.classList.remove('slide');
                 element.classList.remove('slide');
-                element.classList.remove(options.cssClass);
-                element.style[options.cssRule] = null;
+                element.style.height = null;
 
 
-                if (options.finishCallback) {
-                    window.requestAnimationFrame(options.finishCallback);
+                if (finishCallback) {
+                    window.requestAnimationFrame(finishCallback);
                 }
                 }
             }, 500);
             }, 500);
         });
         });
@@ -108,42 +88,52 @@ utils.slideOut = function (element, options) {
 };
 };
 
 
 /**
 /**
- * Slides a element in (i.e. make the element visible)
+ * Slides a element down (i.e. show a hidden element)
  *
  *
- * @param  HTMLElement element the element to slide in
- * @param  object      options the settings of the sliding process
+ * @param  HTMLElement element        the element to slide down
+ * @param  function    finishCallback function to call when the animation has
+ *     been finished (i.e. the element is visible)
+ * @param  function    startCallback  function to call when the animation starts
  * @return void
  * @return void
  */
  */
-utils.slideIn = function (element, options) {
-    var cssRuleOriginalValue = element[options.cssRuleRef] + 'px',
-        slideId = parseInt(element.dataset.slideId) || 0;
+utils.slideDown = function (element, finishCallback, startCallback) {
+    if (!utils.canSlide()) {
+        if (startCallback) startCallback();
+        element.className = element.className.replace(/\bhidden\b */g, '');
+        if (finishCallback) window.requestAnimationFrame(finishCallback);
+        return;
+    }
 
 
-    element.dataset.slideId = ++slideId;
+    var cssRuleOriginalValue = element.clientHeight + 'px',
+        slideId = parseInt(element.getAttribute('data-slide-id')) || 0;
 
 
-    element.style[options.cssRule] = null;
-    element.classList.remove('hidden', 'slide', options.cssClass);
-    var cssRuleValue = element[options.cssRuleRef] + 'px';
+    element.setAttribute('data-slide-id', ++slideId);
 
 
-    element.classList.add('slide');
+    element.style.height = null;
+    element.classList.remove('hidden');
+    element.classList.remove('slide');
+    var cssRuleValue = element.clientHeight + 'px';
+
+    element.style.height = cssRuleOriginalValue;
 
 
     window.requestAnimationFrame(function () {
     window.requestAnimationFrame(function () {
-        element.style[options.cssRule] = cssRuleOriginalValue;
+        element.classList.add('slide');
 
 
         window.requestAnimationFrame(function () {
         window.requestAnimationFrame(function () {
-            element.style[options.cssRule] = cssRuleValue;
+            element.style.height = cssRuleValue;
 
 
-            if (options.startCallback) {
-                options.startCallback();
+            if (startCallback) {
+                startCallback();
             }
             }
 
 
             window.setTimeout(function () {
             window.setTimeout(function () {
-                if (parseInt(element.dataset.slideId) !== slideId) return;
+                if (parseInt(element.getAttribute('data-slide-id')) !== slideId) return;
 
 
                 element.classList.remove('slide');
                 element.classList.remove('slide');
-                element.style[options.cssRule] = null;
+                element.style.height = null;
 
 
-                if (options.finishCallback) {
-                    window.requestAnimationFrame(options.finishCallback);
+                if (finishCallback) {
+                    window.requestAnimationFrame(finishCallback);
                 }
                 }
             }, 500);
             }, 500);
         });
         });
@@ -151,11 +141,11 @@ utils.slideIn = function (element, options) {
 };
 };
 
 
 /**
 /**
- * Check whether a element is visible or not
+ * Checks whether a element is visible or not
  *
  *
- * @param  HTMLElement element the element to test
+ * @param  HTMLElement element the element to check
  * @return boolean             TRUE when the element is visible, FALSE otherwise
  * @return boolean             TRUE when the element is visible, FALSE otherwise
  */
  */
 utils.isElementVisible = function (element) {
 utils.isElementVisible = function (element) {
     return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
     return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
-};
+};

+ 54 - 45
themes/default/style.css

@@ -7,6 +7,7 @@
  *
  *
  * Pico is a stupidly simple, blazing fast, flat file CMS.
  * Pico is a stupidly simple, blazing fast, flat file CMS.
  *
  *
+ * @author  Gilbert Pellegrom
  * @author  Daniel Rudolf
  * @author  Daniel Rudolf
  * @link    http://picocms.org
  * @link    http://picocms.org
  * @license http://opensource.org/licenses/MIT The MIT License
  * @license http://opensource.org/licenses/MIT The MIT License
@@ -20,15 +21,8 @@
     padding: 0;
     padding: 0;
 }
 }
 
 
-body {
-    font-family: 'Droid Sans', 'Helvetica', 'Arial', sans-serif;
-    font-size: 16px;
-    line-height: 1.6;
-    color: #444;
-}
-
-p, hr, table, .table-responsive, ol, ul, dl, pre, blockquote {
-    margin-bottom: 1em;
+article, aside, dialog, figcaption, figure, footer, header, hgroup, main, nav, section {
+    display:block
 }
 }
 
 
 .hidden { display: none !important; }
 .hidden { display: none !important; }
@@ -48,19 +42,17 @@ p, hr, table, .table-responsive, ol, ul, dl, pre, blockquote {
     -webkit-transition: height .5s ease-in !important;
     -webkit-transition: height .5s ease-in !important;
             transition: height .5s ease-in !important;
             transition: height .5s ease-in !important;
 }
 }
-.slide.up { height: 0 !important; }
 
 
 /*** BASIC LAYOUT ***/
 /*** BASIC LAYOUT ***/
 
 
-html { height: 100%; }
-body {
-    display: flex;
-    flex-direction: column;
-    height: 100%;
-}
+html, body { height: 100%; }
+
+body { display: flex; flex-direction: column; }
+main { flex: 1 0 auto; }
+header, footer { flex: 0 0 auto; }
+
 main {
 main {
-    flex: 1 0 auto;
-    margin: 5em 0 4em;
+    padding: 5em 0 4em;
 }
 }
 
 
 .container {
 .container {
@@ -83,13 +75,14 @@ header { background: #2EAE9B; }
 header h1 {
 header h1 {
     float: left;
     float: left;
     font-size: 2rem;
     font-size: 2rem;
-    margin: 0 1em 1.5em 0;
+    margin: 0;
+    padding: 1.5em 1em 1.5em 0;
 }
 }
 header h1 a, header h1 a:hover { color: #fff; }
 header h1 a, header h1 a:hover { color: #fff; }
 
 
 header nav {
 header nav {
     text-align: right;
     text-align: right;
-    margin: 3em 0;
+    padding: 3em 0;
 }
 }
 header nav ul {
 header nav ul {
     list-style: none;
     list-style: none;
@@ -106,17 +99,7 @@ header nav ul li {
 header nav a, #page-menu-toggle { color: #afe1da; }
 header nav a, #page-menu-toggle { color: #afe1da; }
 header nav .active a, header nav a:hover, #page-menu-toggle:hover { color: #fff; }
 header nav .active a, header nav a:hover, #page-menu-toggle:hover { color: #fff; }
 
 
-#page-menu-toggle {
-    display: none;
-    float: right;
-    width: 2em;
-    margin: 0 0 0.5em 1em;
-    font-size: 1.5rem;
-    line-height: 2em;
-    text-align: center;
-    cursor: pointer;
-}
-#page-menu-toggle > * { vertical-align: middle; }
+#page-menu-toggle { display: none; }
 
 
 /*** BASIC LAYOUT: FOOTER ***/
 /*** BASIC LAYOUT: FOOTER ***/
 
 
@@ -129,35 +112,36 @@ footer a { color: #ddd; }
 footer a:hover { color: #fff; }
 footer a:hover { color: #fff; }
 
 
 footer p {
 footer p {
-    margin: 3em 0;
+    margin: 0;
+    padding: 3em 0;
 }
 }
 
 
 footer .social {
 footer .social {
     float: right;
     float: right;
-    margin: 0 0 0.5em 1em;
+    padding: 1.5em 0 0.5em 1em;
     font-size: 2rem;
     font-size: 2rem;
 }
 }
 
 
 /*** BASIC LAYOUT: EXTRA SMALL DEVICES ***/
 /*** BASIC LAYOUT: EXTRA SMALL DEVICES ***/
 
 
 @media (max-width: 767px) {
 @media (max-width: 767px) {
-    main { margin: 2em 0 1em; }
+    main { padding: 2em 0 1em; }
 
 
     header h1 {
     header h1 {
         float: none;
         float: none;
-        margin: 0.5em 0;
+        padding: 0.5em 0;
     }
     }
 
 
     header nav {
     header nav {
         clear: right;
         clear: right;
-        margin: 0;
+        padding: 0;
     }
     }
     header nav ul {
     header nav ul {
         padding-bottom: 1em;
         padding-bottom: 1em;
     }
     }
     header nav ul li {
     header nav ul li {
         display: block;
         display: block;
-        margin: 0;
+        margin-left: 0;
         text-align: center;
         text-align: center;
     }
     }
     header nav ul li a {
     header nav ul li a {
@@ -165,13 +149,44 @@ footer .social {
         padding: 0.5em 0;
         padding: 0.5em 0;
     }
     }
 
 
-    .js #page-menu-toggle { display: block; }
+    .js #page-menu-toggle {
+        display: block;
+        float: right;
+        width: 2em;
+        margin: 0.6667em 0 0.6667em 1.3333em;
+        font-size: 1.5rem;
+        line-height: 2em;
+        text-align: center;
+        cursor: pointer;
+    }
+    .js #page-menu-toggle > * { vertical-align: middle;  }
 
 
-    footer p { margin: 1em 0; }
+    footer p { padding: 1em 0; }
+    footer .social { padding: 0.5em 0 0.5em 1em; }
 }
 }
 
 
 /*** TEXT ***/
 /*** TEXT ***/
 
 
+body {
+    font-family: 'Droid Sans', 'Helvetica', 'Arial', sans-serif;
+    font-size: 16px;
+    line-height: 1.6;
+    font-variant-ligatures: common-ligatures;
+    text-rendering: optimizeLegibility;
+    font-kerning: normal;
+    color: #444;
+}
+
+p, td, th, li, dd {
+    text-align: justify;
+    overflow-wrap: break-word;
+    word-wrap: break-word;
+}
+
+p, hr, table, .table-responsive, ol, ul, dl, pre, blockquote {
+    margin-bottom: 1em;
+}
+
 a {
 a {
     color: #2EAE9B;
     color: #2EAE9B;
     text-decoration: none;
     text-decoration: none;
@@ -194,12 +209,6 @@ h6 { font-size: 1rem; font-weight: normal; font-style: italic; }
 
 
 img { max-width: 100%; }
 img { max-width: 100%; }
 
 
-p, td, th, li, dd {
-    text-align: justify;
-    overflow-wrap: break-word;
-    word-wrap: break-word;
-}
-
 hr {
 hr {
     border: 0.15em solid #f5f5f5;
     border: 0.15em solid #f5f5f5;
     border-radius: 0.3em;
     border-radius: 0.3em;

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor