@ -764,47 +764,49 @@
} ( ) ;
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* PullToRefresh v0 . 004
* PullToRefresh v0 . 007
* By Simon Waldherr
* https : //github.com/SimonWaldherr/PullToRefresh
* Licensed under The MIT License
* http : //opensource.org/licenses/MIT
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- * /
var ptr _scrollable _parent = false ;
function ptr _init ( ) {
var ptr = [ ] ;
var ptr _init = function ( ) {
"use strict" ;
var ptr _box , ptr _container , ptr _image , ptr _text , i = 0 , scrollables = document . getElementsByClassName ( 'scrollable' ) ;
var i = 0 ;
ptr . scrollable _parent = false ;
ptr . scrollables = document . getElementsByClassName ( 'ptr_scrollable' ) ;
if ( ( window . hasOwnProperty ( 'ontouchstart' ) ) || ( window . navigator . msPointerEnabled ) ) {
document . getElementsByTagName ( 'body' ) [ 0 ] . className += ' touch' ;
} else {
document . getElementsByTagName ( 'body' ) [ 0 ] . className += ' notouch' ;
}
for ( i = 0 ; i < scrollables . length ; i += 1 ) {
if ( scrollables [ i ] . hasAttribute ( 'data-url' ) !== false ) {
ptr _box = document . createElement ( 'div' ) ;
ptr _container = document . createElement ( 'div' ) ;
ptr _image = document . createElement ( 'div' ) ;
ptr _text = document . createElement ( 'div' ) ;
ptr _box . appendChild ( ptr _container ) ;
ptr _container . appendChild ( ptr _image ) ;
ptr _container . appendChild ( ptr _text ) ;
ptr _text . innerHTML = 'Pull to refresh' ;
ptr _box . className = 'ptr_box' ;
ptr _container . className = 'ptr_container' ;
ptr _image . className = 'ptr_image' ;
ptr _text . className = 'ptr_text' ;
scrollables [ i ] . firstElementChild . insertBefore ( ptr _box , scrollables [ i ] . firstElementChild . firstChild ) ;
for ( i = 0 ; i < ptr . scrollables . length ; i += 1 ) {
if ( ptr . scrollables [ i ] . hasAttribute ( 'data-url' ) !== false ) {
ptr . box = document . createElement ( 'div' ) ;
ptr . container = document . createElement ( 'div' ) ;
ptr . image = document . createElement ( 'div' ) ;
ptr . text = document . createElement ( 'div' ) ;
ptr . box . appendChild ( ptr . container ) ;
ptr . container . appendChild ( ptr . image ) ;
ptr . container . appendChild ( ptr . text ) ;
ptr . text . innerHTML = 'Pull to refresh' ;
ptr . box . className = 'ptr_box' ;
ptr . box . style . right = '99%' ;
ptr . container . className = 'ptr_container' ;
ptr . image . className = 'ptr_image' ;
ptr . text . className = 'ptr_text' ;
ptr . scrollables [ i ] . firstElementChild . insertBefore ( ptr . box , ptr . scrollables [ i ] . firstElementChild . firstChild ) ;
}
}
document . addEventListener ( 'touchstart' , function ( e ) {
var ptr _box , ptr _container , ptr _image , ptr _text , p arent = e . target , i = 0 ;
var parent = e . target , i = 0 ;
if ( parent . className === undefined ) {
return false ;
@ -813,29 +815,33 @@ function ptr_init() {
for ( i = 0 ; i < 10 ; i += 1 ) {
if ( parent . className !== undefined ) {
if ( parent . className . match ( 'scrollable' ) ) {
if ( parent . className . match ( 'ptr_ scrollable' ) ) {
ptr _ scrollable_parent = i ;
ptr . scrollable _parent = i ;
i = 10 ;
if ( parent . hasAttribute ( 'data-url' ) !== false ) {
if ( parent . getElementsByClassName ( 'ptr_box' ) [ 0 ] === undefined ) {
ptr _box = document . createElement ( 'div' ) ;
ptr _container = document . createElement ( 'div' ) ;
ptr _image = document . createElement ( 'div' ) ;
ptr _text = document . createElement ( 'div' ) ;
ptr _box . appendChild ( ptr _container ) ;
ptr _container . appendChild ( ptr _image ) ;
ptr _container . appendChild ( ptr _text ) ;
ptr _text . innerHTML = 'Pull to refresh' ;
ptr _box . className = 'ptr_box' ;
ptr _container . className = 'ptr_container' ;
ptr _image . className = 'ptr_image' ;
ptr _text . className = 'ptr_text' ;
parent . firstElementChild . insertBefore ( ptr _box , parent . firstElementChild . firstChild ) ;
ptr . box = document . createElement ( 'div' ) ;
ptr . container = document . createElement ( 'div' ) ;
ptr . image = document . createElement ( 'div' ) ;
ptr . text = document . createElement ( 'div' ) ;
ptr . box . appendChild ( ptr . container ) ;
ptr . container . appendChild ( ptr . image ) ;
ptr . container . appendChild ( ptr . text ) ;
ptr . text . innerHTML = 'Pull to refresh' ;
ptr . box . className = 'ptr_box' ;
ptr . box . style . right = '0px' ;
ptr . container . className = 'ptr_container' ;
ptr . image . className = 'ptr_image' ;
ptr . text . className = 'ptr_text' ;
parent . firstElementChild . insertBefore ( ptr . box , parent . firstElementChild . firstChild ) ;
} else {
parent . getElementsByClassName ( 'ptr_box' ) [ 0 ] . style . opacity = 1.0 ;
parent . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = 'Pull to refresh' ;
}
} else if ( parent . getElementsByClassName ( 'ptr_box' ) [ 0 ] !== undefined ) {
parent . removeChild ( parent . getElementsByClassName ( 'ptr_box' ) [ 0 ] ) ;
@ -843,6 +849,7 @@ function ptr_init() {
if ( parent . scrollTop === 0 ) {
parent . scrollTop = 1 ;
parent . getElementsByClassName ( 'ptr_wrap' ) [ 0 ] . style . top = '1px' ;
} else if ( ( parent . scrollTop + parent . offsetHeight ) === parent . scrollHeight ) {
parent . scrollTop = parent . scrollTop - 1 ;
}
@ -863,52 +870,52 @@ function ptr_init() {
} ) ;
document . addEventListener ( 'touchmove' , function ( e ) {
var parent = e . target , scroll = false , rotate = 90 , i = 0 , ptr _element , ptr _wrapelement , top , ptr , scrolldistance , ptr _eleId , time , ptrbox , insert , inserted ;
if ( ptr _scrollable _parent === false ) {
var parent = e . target , scroll = false , rotate = 90 , i = 0 , top , scrolldistance , time , insert , inserted ;
if ( ptr . scrollable _parent === false ) {
e . preventDefault ( ) ;
return false ;
}
for ( i = 0 ; i < ptr _ scrollable_parent ; i += 1 ) {
for ( i = 0 ; i < ptr . scrollable _parent ; i += 1 ) {
parent = parent . parentNode ;
}
if ( ( ptr _ scrollable_parent !== false ) && ( parent . hasAttribute ( 'data-url' ) !== false ) ) {
if ( ( ptr . scrollable _parent !== false ) && ( parent . hasAttribute ( 'data-url' ) !== false ) ) {
scroll = true ;
ptr _ element = parent ;
ptr _ wrapelement = ptr _ element. getElementsByClassName ( 'wrap' ) [ 0 ] ;
top = ptr _ element. scrollTop ;
ptr = ptr _ element. getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
scrolldistance = Math . abs ( parseInt ( ptr _ element. scrollTop , 10 ) ) ;
ptr . element = parent ;
ptr . wrapelement = ptr . element . getElementsByClassName ( 'ptr_ wrap' ) [ 0 ] ;
top = ptr . element . scrollTop ;
ptr . box = ptr . element . getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
scrolldistance = Math . abs ( ptr . element . scrollTop ) ;
if ( ( ptr _ wrapelement. className . indexOf ( ' active' ) === - 1 ) && ( ! ptr _ wrapelement. getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . match ( 'loading' ) ) && ( ptr _ element. scrollTop < 1 ) ) {
if ( ptr _ element. scrollTop < - 25 ) {
rotate = ( top < - 40 ) ? - 90 : 130 + ( top * 12 + 270 ) ;
if ( ( ptr . wrapelement . className . indexOf ( ' active' ) === - 1 ) && ( ! ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . match ( 'ptr_ loading' ) ) && ( ptr . element . scrollTop < 1 ) ) {
if ( ptr . element . scrollTop < - 25 ) {
rotate = ( top < - 40 ) ? - 90 : 130 + parseInt ( top * 12 + 270 , 1 0 ) ;
}
if ( ptr _element . scrollTop < 0 ) {
ptr . style . height = ( scrolldistance < 55 ) ? scrolldistance + 'px' : '55px' ;
ptr . style . top = ( scrolldistance < 55 ) ? '-' + scrolldistance + 'px' : '-55px' ;
ptr _wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . style [ '-webkit-transform' ] = "scale(1) rotate(" + rotate + "deg)" ;
if ( ptr . element . scrollTop < 0 ) {
ptr . box . style . right = '0px' ;
ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . style [ '-webkit-transform' ] = 'scale(1) rotate(' + rotate + 'deg)' ;
}
if ( ptr _element . scrollTop < - 51 ) {
if ( ptr _wrapelement . className . indexOf ( ' active' ) === - 1 ) {
ptr _wrapelement . className += ' active' ;
ptr _wrapelement . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = 'Loading ...' ;
ptr _wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className += ' loading' ;
if ( ptr . element . scrollTop < - 51 ) {
if ( ptr . wrapelement . className . indexOf ( ' ptr_active' ) === - 1 ) {
ptr . box . style . right = '0px' ;
ptr . wrapelement . className += ' ptr_active' ;
ptr . wrapelement . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = 'Loading ...' ;
ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className += ' ptr_loading' ;
if ( parent . getAttribute ( 'data-url' ) === 'reload' ) {
window . location . reload ( true ) ;
return false ;
}
ptr _ element = parent ;
ptr _ wrapelement = ptr _ element. getElementsByClassName ( 'wrap' ) [ 0 ] ;
ptr _ eleId = parent . id ;
ptr . element = parent ;
ptr . wrapelement = ptr . element . getElementsByClassName ( 'ptr_ wrap' ) [ 0 ] ;
ptr . eleId = parent . id ;
time = new Date ( ) ;
reqwest ( {
@ -920,38 +927,39 @@ function ptr_init() {
} ,
error : function ( ) {
alert ( 'Could not connect' ) ;
ptr _ wrapelement. style . top = '0px' ;
ptr . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' loading' , '' ) ;
ptr _ wrapelement. className = ptr _ wrapelement. className . replace ( ' active' , '' ) ;
ptr . wrapelement . style . top = '0px' ;
ptr . box . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' loading' , '' ) ;
ptr . wrapelement . className = ptr . wrapelement . className . replace ( ' ptr_ active' , '' ) ;
} ,
success : function ( resp ) {
ptrbox = document . getElementById ( ptr _ eleId) . getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
ptr . box = document . getElementById ( ptr . eleId ) . getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
insert = document . createElement ( 'div' ) ;
insert . innerHTML = resp ;
insert . className = 'inserted' ;
insert . className = 'ptr_ inserted' ;
ptr _ wrapelement. insertBefore ( insert , ptrbox . nextSibling ) ;
ptr _ wrapelement. style . top = '0px' ;
ptr . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' loading' , '' ) ;
ptr _ wrapelement. className = ptr _ wrapelement. className . replace ( ' active' , '' ) ;
inserted = document . getElementsByClassName ( 'inserted' ) [ 0 ] ;
ptr _ element. scrollTop = inserted . clientHeight - 51 ;
ptr _ wrapelement. getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = '' ;
ptr . style . opacity = 0.0 ;
ptr . wrapelement . insertBefore ( insert , ptr . box . nextSibling ) ;
ptr . wrapelement . style . top = '0px' ;
ptr . box . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr . box . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' ptr_ loading' , '' ) ;
ptr . wrapelement . className = ptr . wrapelement . className . replace ( ' ptr_ active' , '' ) ;
inserted = document . getElementsByClassName ( 'ptr_ inserted' ) [ 0 ] ;
ptr . element . scrollTop = inserted . clientHeight - 51 ;
ptr . wrapelement . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = '' ;
ptr . box . style . right = '99%' ;
ptr _wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr _wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' loading' , '' ) ;
ptr _wrapelement . style . top = '0px' ;
ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className = ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . replace ( ' ptr_loading' , '' ) ;
ptr _ scrollable_parent = false ;
ptr . scrollable _parent = false ;
}
} ) ;
}
} else if ( ptr _element . scrollTop !== 0 ) {
ptr _wrapelement . className = ptr _wrapelement . className . replace ( ' active' , '' ) ;
ptr _wrapelement . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = 'Pull to refresh' ;
} else if ( ptr . element . scrollTop !== 0 ) {
if ( ptr . wrapelement . className . indexOf ( ' active' ) !== - 1 ) {
ptr . wrapelement . className = ptr . wrapelement . className . replace ( ' ptr_active' , '' ) ;
ptr . wrapelement . getElementsByClassName ( 'ptr_text' ) [ 0 ] . innerHTML = 'Pull to refresh' ;
}
}
}
} else if ( ( ptr _ scrollable_parent !== false ) ) {
} else if ( ( ptr . scrollable _parent !== false ) ) {
scroll = true ;
}
@ -961,32 +969,32 @@ function ptr_init() {
} ) ;
document . addEventListener ( 'touchend' , function ( e ) {
var parent = e . target , i = 0 , ptr _element , ptr _wrapelement , ptr _eleId , top , ptr ;
var parent = e . target , i = 0 , top ;
for ( i = 0 ; i < ptr _ scrollable_parent ; i += 1 ) {
for ( i = 0 ; i < ptr . scrollable _parent ; i += 1 ) {
parent = parent . parentNode ;
}
if ( ( parent . hasAttribute ( 'data-url' ) !== false ) && ( ptr _ scrollable_parent !== false ) ) {
if ( ( parent . hasAttribute ( 'data-url' ) !== false ) && ( ptr . scrollable _parent !== false ) ) {
if ( ( parent . hasAttribute ( 'data-url' ) !== false ) ) {
ptr _ element = parent ;
ptr _ wrapelement = ptr _ element. getElementsByClassName ( 'wrap' ) [ 0 ] ;
ptr _ eleId = parent . id ;
top = ptr _ element. scrollTop ;
ptr = ptr _ element. getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
if ( ptr _ wrapelement. getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . match ( 'loading' ) ) {
ptr _ wrapelement. className = ptr _ wrapelement. className . replace ( ' active' , '' ) ;
ptr _ wrapelement. style . top = '51px' ;
ptr . element = parent ;
ptr . wrapelement = ptr . element . getElementsByClassName ( 'ptr_ wrap' ) [ 0 ] ;
ptr . eleId = parent . id ;
top = ptr . element . scrollTop ;
ptr . box = ptr . element . getElementsByClassName ( 'ptr_box' ) [ 0 ] ;
if ( ptr . wrapelement . getElementsByClassName ( 'ptr_image' ) [ 0 ] . className . match ( 'ptr_ loading' ) ) {
ptr . wrapelement . className = ptr . wrapelement . className . replace ( ' ptr_ active' , '' ) ;
ptr . wrapelement . style . top = '51px' ;
} else {
ptr . style . height = '0px' ;
ptr . style . top = '0px' ;
ptr . box . style . right = '99%' ;
}
}
}
ptr _scrollable _parent = false ;
ptr . scrollable _parent = false ;
} ) ;
}
} ;
window . onload = function ( ) {
ptr _init ( ) ;
}