|
|
@@ -9,56 +9,61 @@
|
|
|
|
|
|
Lungo.Boot.Layout = (function(lng, undefined) {
|
|
|
|
|
|
- var _window = null;
|
|
|
- var _document = null;
|
|
|
-
|
|
|
var ELEMENT = lng.Constants.ELEMENT;
|
|
|
+ var CLASS = lng.Constants.CLASS;
|
|
|
var ATTRIBUTE = lng.Constants.ATTRIBUTE;
|
|
|
+ var QUERY = lng.Constants.QUERY;
|
|
|
|
|
|
/**
|
|
|
- * Initializes the automatic subscription events by markup of the project.
|
|
|
+ * Initializes all <section> & <article> of the project
|
|
|
*
|
|
|
* @method init
|
|
|
*
|
|
|
*/
|
|
|
var init = function() {
|
|
|
- if (lng.Core.isMobile()) {
|
|
|
- _resizeLayout();
|
|
|
- }
|
|
|
+ lng.Element.Cache.asides = lng.dom(ELEMENT.ASIDE);
|
|
|
+ lng.Fallback.fixPositionInAndroid();
|
|
|
+
|
|
|
+ _initFirstSection();
|
|
|
+ _initArticleElement(QUERY.LIST_IN_ARTICLE, _createListElement);
|
|
|
+ _initArticleElement(QUERY.ARTICLE_SCROLLABLE, _scrollFix);
|
|
|
};
|
|
|
|
|
|
- var _resizeLayout = function() {
|
|
|
- _window = window;
|
|
|
- if (_window.innerHeight == 356) {
|
|
|
- var _height = 416;
|
|
|
+ var _initFirstSection = function() {
|
|
|
+ var section = lng.dom(ELEMENT.SECTION).first().addClass(CLASS.SHOW);
|
|
|
+ lng.Element.Cache.section = section;
|
|
|
+ lng.Element.Cache.article = section.children(ELEMENT.ARTICLE + "." + CLASS.ACTIVE);
|
|
|
|
|
|
- lng.dom(ELEMENT.BODY).style(ATTRIBUTE.HEIGHT, _height + ATTRIBUTE.PIXEL);
|
|
|
- _hideNavigationBar();
|
|
|
- }
|
|
|
+ var section_id = '#' + section.attr(ATTRIBUTE.ID);
|
|
|
+ lng.Router.History.add(section_id);
|
|
|
};
|
|
|
|
|
|
- var _hideNavigationBar = function() {
|
|
|
- if( !location.hash || !_window.addEventListener ) {
|
|
|
- _document = _window.document;
|
|
|
+ var _initArticleElement = function(selector, callback) {
|
|
|
+ var found_elements = lng.dom(selector);
|
|
|
+ for (var i = 0, len = found_elements.length; i < len; i++) {
|
|
|
+ var element = lng.dom(found_elements[i]);
|
|
|
+ lng.Core.execute(callback, element);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- _window.scrollTo( 0, 1 );
|
|
|
- var scrollTop = 1,
|
|
|
+ var _createListElement = function(article) {
|
|
|
+ if (article.children().length === 0) {
|
|
|
+ var article_id = article.attr(ATTRIBUTE.ID);
|
|
|
+ article.append(ELEMENT.LIST);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- //reset to 0 on bodyready, if needed
|
|
|
- bodycheck = setInterval(function(){
|
|
|
- if( _document.body ){
|
|
|
- clearInterval( bodycheck );
|
|
|
- scrollTop = 'scrollTop' in _document.body ? _document.body.scrollTop : 1;
|
|
|
- _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
|
|
|
- }
|
|
|
- }, 15 );
|
|
|
|
|
|
- _window.addEventListener('load', function(){
|
|
|
- setTimeout(function(){
|
|
|
- _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
|
|
|
- }, 0);
|
|
|
- }, false );
|
|
|
- }
|
|
|
+ var _scrollFix = function(article) {
|
|
|
+ article[0].addEventListener('touchstart', function(event) {
|
|
|
+ scrollTop = this.scrollTop;
|
|
|
+ if(scrollTop <= 1) {
|
|
|
+ this.scrollTop = 1;
|
|
|
+ }
|
|
|
+ if(scrollTop + this.offsetHeight >= this.scrollHeight) {
|
|
|
+ this.scrollTop = this.scrollHeight - this.offsetHeight - 1;
|
|
|
+ }
|
|
|
+ }, false);
|
|
|
};
|
|
|
|
|
|
return {
|