2016-08-18 20:39:31 +00:00
/ * *
* Peafowl JS
* Copyright 2016 Rodolfo Berrios < www . rodolfoberrios . com >
* /
/ * *
* Peafowl DOM functions and event listeners
* /
$ ( function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ . ajaxSetup ( {
2018-04-17 21:25:26 +00:00
url : PF . obj . config . json _api ,
cache : false ,
dataType : "json" ,
data : { auth _token : PF . obj . config . auth _token }
} ) ;
2016-08-18 20:39:31 +00:00
/ * *
* WINDOW LISTENERS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
$ ( window ) . bind ( "beforeunload" , function ( ) {
2016-08-18 20:39:31 +00:00
if ( $ ( "form" , PF . obj . modal . selectors . root ) . data ( "beforeunload" ) == "continue" ) return ;
if ( $ ( PF . obj . modal . selectors . root ) . is ( ":visible" ) && PF . fn . form _modal _has _changed ( ) ) {
return PF . fn . _s ( "All the changes that you have made will be lost if you continue." ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
$ ( window ) . bind ( "hashchange" , function ( ) {
2016-08-18 20:39:31 +00:00
// Call edit modal on #edit
if ( window . location . hash == "#edit" && ! $ ( PF . obj . modal . selectors . root ) . exists ( ) ) $ ( "[data-modal=edit]" ) . first ( ) . click ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Blind the tipTips on load
PF . fn . bindtipTip ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var resizeTimer , scrollTimer , width = $ ( window ) . width ( ) ;
// Fluid width on resize
$ ( window ) . on ( "resize" , function ( ) {
PF . fn . growl . fixPosition ( ) ;
PF . fn . modal . fixScrollbars ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var device = PF . fn . getDeviceName ( ) ,
handled = [ "phone" , "phablet" ] ,
desktop = [ "tablet" , "laptop" , "desktop" ] ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
clearTimeout ( resizeTimer ) ;
clearTimeout ( scrollTimer ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
scrollTimer = setTimeout ( function ( ) {
2016-11-06 02:19:47 +00:00
$ ( ".follow-scroll-wrapper, .follow-scroll-placeholder" ) . css ( { minHeight : "" } ) ;
PF . obj . follow _scroll . set ( true ) ;
PF . obj . follow _scroll . process ( true ) ;
2016-08-18 20:39:31 +00:00
} , 100 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
//PF.fn.window_to_device(); // handled by window event parent
var new _device = PF . fn . getDeviceName ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( new _device !== device && ( $ . inArray ( device , handled ) >= 0 && $ . inArray ( new _device , handled ) == - 1 ) || ( $ . inArray ( device , desktop ) >= 0 && $ . inArray ( new _device , desktop ) == - 1 ) ) {
PF . fn . close _pops ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".top-bar" ) . css ( "top" , "" ) ;
$ ( PF . fn . topMenu . vars . menu ) . css ( "height" , $ ( window ) . height ( ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "body" ) . css ( { position : "" , height : "" } ) ;
$ ( ".antiscroll" ) . removeClass ( "jsly" ) . data ( "antiscroll" , "" ) ; // Destroy for this?
$ ( ".antiscroll-inner" ) . css ( { height : "" , width : "" , maxheight : "" } ) ; // .pop-box, .pop-box-inner ?
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . list _fluid _width ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( width !== $ ( window ) . width ( ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( "[data-action=top-bar-menu-full]" , "#top-bar" ) . hasClass ( "current" ) ) {
PF . fn . topMenu . hide ( 0 ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var cols _fn = function ( ) {
PF . fn . listing . columnizer ( true , 0 ) ;
$ ( PF . obj . listing . selectors . list _item ) . show ( ) ;
} ;
cols _fn ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
width = $ ( window ) . width ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Close the opened pop-boxes on HTML click
$ ( document ) . on ( "click" , "html" , function ( ) {
PF . fn . close _pops ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* SMALL HELPERS AND THINGS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Attemp to replace .svg with .png for browsers that doesn't support it
if ( $ ( "html" ) . hasClass ( "no-svg" ) ) {
$ ( "img.replace-svg" ) . replace _svg ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Keydown numeric input (prevents non numeric keys)
$ ( document ) . on ( "keydown" , ".numeric-input" , function ( e ) {
e . keydown _numeric ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// The handly data-scrollto. IT will scroll the elements to the target
$ ( document ) . on ( "click" , "[data-scrollto]" , function ( e ) {
var target = $ ( this ) . data ( "scrollto" ) ,
$target = $ ( ! target . match ( /^\#|\./ ) ? "#" + target : target ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target . exists ( ) ) {
PF . fn . scroll ( $target ) ;
} else {
console . log ( "PF scrollto error: target doesn't exists" , $target ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// The handly data-trigger. It will trigger click for elements with data-trigger
$ ( document ) . on ( "click" , "[data-trigger]" , function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var trigger = $ ( this ) . data ( "trigger" ) ,
$target = $ ( ! trigger . match ( /^\#|\./ ) ? "#" + trigger : trigger ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target . exists ( ) ) {
e . stopPropagation ( ) ;
e . preventDefault ( ) ;
if ( ! $target . closest ( PF . obj . modal . selectors . root ) . length ) {
PF . fn . modal . close ( ) ;
}
$target . click ( ) ;
} else {
console . log ( "PF trigger error: target doesn't exists" , $target ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Fix the auth_token inputs
$ ( "form[method=post]" ) . each ( function ( ) {
if ( ! $ ( "input[name=auth_token]" , this ) . exists ( ) ) {
$ ( this ) . append ( $ ( '<input>' , { type : 'hidden' , name : "auth_token" , value : PF . obj . config . auth _token } ) ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Clear form like magic
$ ( document ) . on ( "click" , ".clear-form" , function ( ) {
$ ( this ) . closest ( "form" ) [ 0 ] . reset ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( document ) . on ( "submit" , "form[data-action=validate]" , function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var type = $ ( this ) . data ( "type" ) ,
errors = false ,
$validate = $ ( this ) . find ( "[required], [data-validate]" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$validate . each ( function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var input _type = $ ( this ) . attr ( "type" ) ,
pattern = $ ( this ) . attr ( "pattern" ) ,
errorFn = function ( el ) {
$ ( el ) . highlight ( ) ;
errors = true ;
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . is ( "[required]" ) && $ ( this ) . val ( ) == "" ) {
if ( $ ( this ) . is ( ":hidden" ) ) {
var $hidden _target = $ ( $ ( $ ( this ) . data ( "highlight" ) ) . exists ( ) ? $ ( this ) . data ( "highlight" ) : "#" + $ ( this ) . data ( "highlight" ) ) ;
$ ( $hidden _target ) . highlight ( ) ;
}
errorFn ( this ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof pattern == "undefined" && /mail|url/ . test ( input _type ) == false ) {
return true ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( pattern ) {
pattern = new RegExp ( pattern ) ;
if ( ! pattern . test ( $ ( this ) . val ( ) ) ) {
errorFn ( this ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( input _type == "email" && ! $ ( this ) . val ( ) . isEmail ( ) ) {
errorFn ( this ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
if ( errors ) {
PF . fn . growl . expirable ( PF . fn . _s ( "Check the errors in the form to continue." ) ) ;
return false ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Co-combo breaker
$ ( document ) . on ( "change" , "select[data-combo]" , function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $combo = $ ( "#" + $ ( this ) . data ( "combo" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $combo . exists ( ) ) {
$combo . children ( ".switch-combo" ) . hide ( ) ;
}
var $combo _container = $ ( "#" + $ ( this ) . closest ( "select" ) . data ( "combo" ) ) ,
$combo _target = $ ( "[data-combo-value~=" + $ ( "option:selected" , this ) . attr ( "value" ) + "]" , $combo _container ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $combo _target . exists ( ) ) {
$combo _target
. show ( )
. find ( "[data-required]" )
. each ( function ( ) {
$ ( this ) . attr ( "required" , "required" ) ; // re-enable any disabled required
} ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Disable [required] in hidden combos
$ ( ".switch-combo" , $combo _container ) . each ( function ( ) {
if ( $ ( this ) . is ( ":visible" ) ) return ;
$ ( "[required]" , this ) . attr ( "data-required" , true ) . removeAttr ( "required" ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Y COMO DICE: ESCAPE FROM THE PLANET OF THE APES
$ ( document ) . on ( "keyup" , function ( e ) {
$this = $ ( e . target ) ;
if ( e . keyCode == 27 ) {
if ( $ ( PF . obj . modal . selectors . root ) . is ( ":visible" ) && ! $this . is ( ":input" ) ) {
$ ( "[data-action=cancel],[data-action=close-modal]" , PF . obj . modal . selectors . root ) . first ( ) . click ( ) ;
}
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Input events
$ ( document ) . on ( "change" , ":input" , function ( e ) {
PF . fn . growl . close ( ) ;
} ) ;
$ ( document ) . on ( "keyup" , ":input" , function ( e ) {
$ ( ".input-warning" , $ ( this ) . closest ( ".input-label" ) ) . html ( "" ) ;
} ) ;
$ ( document ) . on ( "blur" , ":input" , function ( ) {
var this _val = $ . trim ( $ ( this ) . prop ( "value" ) ) ;
$ ( this ) . prop ( "value" , this _val ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Select all on an input type
$ ( document ) . on ( "click" , ":input[data-focus=select-all]" , function ( ) {
this . select ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Input password strength
$ ( document ) . on ( "keyup change blur" , ":input[type=password]" , function ( ) {
var password = testPassword ( $ ( this ) . val ( ) ) ,
$parent = $ ( this ) . closest ( "div" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . val ( ) == "" ) {
password . percent = 0 ;
password . verdict = "" ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "[data-content=password-meter-bar]" , $parent ) . width ( password . percent ) ;
$ ( "[data-text=password-meter-message]" , $parent ) . removeClass ( "red-warning" ) . text ( password . verdict !== "" ? PF . fn . _s ( password . verdict ) : "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Popup links
$ ( document ) . on ( "click" , "[rel=popup-link], .popup-link" , function ( e ) {
e . preventDefault ( ) ;
var href = $ ( this ) [ typeof $ ( this ) . attr ( "href" ) !== "undefined" ? "attr" : "data" ] ( "href" ) ;
if ( typeof href == "undefined" ) {
return ;
}
if ( href . substring ( 0 , 6 ) == "mailto" && PF . fn . isDevice ( [ "phone" , "phablet" ] ) ) {
window . location = href ;
return false ;
}
PF . fn . popup ( { href : href } ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* FOWLLOW SCROLL
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
$ ( window ) . scroll ( function ( ) {
PF . obj . follow _scroll . process ( ) ; // todo:optimize
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* MODAL
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Call plain simple HTML modal
$ ( document ) . on ( "click" , "[data-modal=simple],[data-modal=html]" , function ( ) {
var $target = $ ( "[data-modal=" + $ ( this ) . data ( "target" ) + "], #" + $ ( this ) . data ( "target" ) ) . first ( ) ;
PF . fn . modal . call ( { template : $target . html ( ) , buttons : false } ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Prevent modal submit form since we only use the form in the modal to trigger HTML5 validation
$ ( document ) . on ( "submit" , PF . obj . modal . selectors . root + " form" , function ( e ) {
if ( $ ( this ) . data ( "prevented" ) ) return false ; // Don't send the form if is prevented
if ( typeof $ ( this ) . attr ( "method" ) !== "undefined" ) return ; // Don't bind anything extra if is normal form
return false ; // Prevent default form handling
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Form/editable/confirm modal
$ ( document ) . on ( "click" , "[data-modal=edit],[data-modal=form],[data-confirm]" , function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
e . preventDefault ( ) ;
2018-04-17 21:25:26 +00:00
2017-11-09 19:02:18 +00:00
var $this = $ ( this ) ;
var $target ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $this . is ( "[data-confirm]" ) ) {
$target = $this ;
PF . obj . modal . type = "confirm" ;
} else {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$target = $ ( "[data-modal=" + $this . data ( "target" ) + "], #" + $this . data ( "target" ) ) . first ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target . length == 0 ) {
$target = $ ( "[data-modal=form-modal], #form-modal" ) . first ( ) ;
}
if ( $target . length == 0 ) {
console . log ( "PF Error: Modal target doesn't exists." ) ;
}
PF . obj . modal . type = $this . data ( "modal" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var args = $this . data ( "args" ) ,
submit _function = window [ $target . data ( "submit-fn" ) ] ,
cancel _function = window [ $target . data ( "cancel-fn" ) ] ,
onload _function = window [ $target . data ( "load-fn" ) ] ,
submit _done _msg = $target . data ( "submit-done" ) ,
ajax = {
2017-11-09 19:02:18 +00:00
url : $target . data ( "ajax-url" ) || ( typeof $target . data ( "is-xhr" ) !== typeof undefined ? PF . obj . config . json _api : null ) ,
2016-08-18 20:39:31 +00:00
deferred : window [ $target . data ( "ajax-deferred" ) ]
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Window functions failed? Maybe those are named fn...
if ( typeof submit _function !== "function" && $target . data ( "submit-fn" ) ) {
var submit _fn _split = $target . data ( "submit-fn" ) . split ( "." ) ;
submit _function = window ;
for ( var i = 0 ; i < submit _fn _split . length ; i ++ ) {
submit _function = submit _function [ submit _fn _split [ i ] ] ;
}
}
if ( typeof cancel _function !== "function" && $target . data ( "cancel-fn" ) ) {
var cancel _fn _split = $target . data ( "cancel-fn" ) . split ( "." ) ;
cancel _function = window ;
for ( var i = 0 ; i < cancel _fn _split . length ; i ++ ) {
cancel _function = cancel _function [ cancel _fn _split [ i ] ] ;
}
}
if ( typeof load _function !== "function" && $target . data ( "load-fn" ) ) {
var load _fn _split = $target . data ( "load-fn" ) . split ( "." ) ;
load _function = window ;
for ( var i = 0 ; i < load _fn _split . length ; i ++ ) {
load _function = load _function [ load _fn _split [ i ] ] ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof ajax . deferred !== "object" && $target . data ( "ajax-deferred" ) ) {
var deferred _obj _split = $target . data ( "ajax-deferred" ) . split ( "." ) ;
ajax . deferred = window ;
for ( var i = 0 ; i < deferred _obj _split . length ; i ++ ) {
ajax . deferred = ajax . deferred [ deferred _obj _split [ i ] ] ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Before fn
var fn _before = window [ $target . data ( "before-fn" ) ] ;
if ( typeof fn _before !== "function" && $target . data ( "before-fn" ) ) {
var before _obj _split = $target . data ( "before-fn" ) . split ( "." ) ;
fn _before = window ;
for ( var i = 0 ; i < before _obj _split . length ; i ++ ) {
fn _before = fn _before [ before _obj _split [ i ] ] ;
}
}
if ( typeof fn _before == "function" ) {
fn _before ( e ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var inline _options = $ ( this ) . data ( "options" ) || { } ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Confirm modal
if ( $this . is ( "[data-confirm]" ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var default _options = {
message : $this . data ( "confirm" ) ,
confirm : typeof submit _function == "function" ? submit _function ( args ) : "" ,
cancel : typeof cancel _function == "function" ? cancel _function ( args ) : "" ,
ajax : ajax
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $this . attr ( "href" ) && default _options . confirm == "" ) {
default _options . confirm = function ( ) {
return window . location . replace ( $this . attr ( "href" ) ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . modal . confirm ( $ . extend ( default _options , inline _options ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} else { // Form/editable
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var default _options = {
template : $target . html ( ) ,
button _submit : $ ( this ) . is ( "[data-modal=edit]" ) ? PF . fn . _s ( "Save changes" ) : PF . fn . _s ( "Submit" ) ,
confirm : function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var form _modal _has _changed = PF . fn . form _modal _has _changed ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Conventional form handling
var $form = $ ( "form" , PF . obj . modal . selectors . root ) ;
if ( typeof $form . attr ( "action" ) !== "undefined" ) {
$form . data ( "prevented" , ! form _modal _has _changed ) ;
PF . fn . modal . close ( ) ;
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Handle the required thing for non-visible elements
$ ( ":input[name]" , $form ) . each ( function ( ) {
if ( ! $ ( this ) . is ( ":visible" ) ) {
var input _attr = $ ( this ) . attr ( "required" ) ;
if ( typeof input _attr !== typeof undefined && input _attr !== false ) {
$ ( this ) . prop ( "required" , false ) . attr ( "data-required" , "required" ) ;
}
} else {
if ( $ ( this ) . attr ( "data-required" ) == "required" ) {
$ ( this ) . prop ( "required" , true ) ;
}
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Detect HTML5 validation
if ( ! $form [ 0 ] . checkValidity ( ) ) {
return false ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Run the full function only when the form changes
if ( ! form _modal _has _changed && ! inline _options . forced ) {
PF . fn . modal . close ( ) ;
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof submit _function == "function" ) submit _fn = submit _function ( ) ;
if ( typeof submit _fn !== "undefined" && submit _fn == false ) {
return false ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ":input" , PF . obj . modal . selectors . root ) . each ( function ( ) {
$ ( this ) . val ( $ . trim ( $ ( this ) . val ( ) ) ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $this . is ( "[data-modal=edit]" ) ) {
// Set the input values before cloning the html
$target . html ( $ ( PF . obj . modal . selectors . body , $ ( PF . obj . modal . selectors . root ) . bindFormData ( ) ) . html ( ) . replace ( /rel=[\'"]tooltip[\'"]/g , 'rel="template-tooltip"' ) ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof ajax . url !== "undefined" ) {
return true ;
} else {
PF . fn . modal . close (
function ( ) {
if ( typeof submit _done _msg !== "undefined" ) {
PF . fn . growl . expirable ( submit _done _msg !== "" ? submit _done _msg : PF . fn . _s ( "Changes saved successfully." ) ) ;
}
}
) ;
}
} ,
cancel : function ( ) {
if ( typeof cancel _fn == "function" ) cancel _fn = cancel _fn ( ) ;
if ( typeof cancel _fn !== "undefined" && cancel _fn == false ) {
return false ;
}
// nota: falta template aca
if ( PF . fn . form _modal _has _changed ( ) ) {
if ( $ ( PF . obj . modal . selectors . changes _confirm ) . exists ( ) ) return ;
$ ( PF . obj . modal . selectors . box , PF . obj . modal . selectors . root ) . css ( { transition : "none" } ) . hide ( ) ;
$ ( PF . obj . modal . selectors . root ) . append ( '<div id="' + PF . obj . modal . selectors . changes _confirm . replace ( "#" , "" ) + '"><div class="content-width"><h2>' + PF . fn . _s ( "All the changes that you have made will be lost if you continue." ) + '</h2><div class="' + PF . obj . modal . selectors . btn _container . replace ( "." , "" ) + ' margin-bottom-0"><button class="btn btn-input default" data-action="cancel">' + PF . fn . _s ( "Go back to form" ) + '</button> <span class="btn-alt">' + PF . fn . _s ( "or" ) + ' <a data-action="submit">' + PF . fn . _s ( "continue anyway" ) + '</a></span></div></div>' ) ;
$ ( PF . obj . modal . selectors . changes _confirm ) . css ( "margin-top" , - $ ( PF . obj . modal . selectors . changes _confirm ) . outerHeight ( true ) / 2 ) . hide ( ) . fadeIn ( "fast" ) ;
} else {
PF . fn . modal . close ( ) ;
if ( window . location . hash == "#edit" ) window . location . hash = "" ;
}
} ,
load : function ( ) {
if ( typeof load _function == "function" ) load _function ( ) ;
2018-04-17 21:25:26 +00:00
} ,
2016-08-18 20:39:31 +00:00
callback : function ( ) { } ,
ajax : ajax
} ;
PF . fn . modal . call ( $ . extend ( default _options , inline _options ) ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Check user login modal -> Must be login to continue
if ( ! PF . fn . is _user _logged ( ) ) {
$ ( "[data-login-needed]:input, [data-user-logged=must]:input" ) . each ( function ( ) {
$ ( this ) . attr ( "readonly" , true ) ;
} ) ;
}
// nota: update junkstr
$ ( document ) . on ( "click focus" , "[data-login-needed], [data-user-logged=must]" , function ( e ) {
if ( ! PF . fn . is _user _logged ( ) ) {
e . preventDefault ( ) ;
e . stopPropagation ( ) ;
if ( $ ( this ) . is ( ":input" ) ) $ ( this ) . attr ( "readonly" , true ) . blur ( ) ;
PF . fn . modal . call ( { type : "login" } ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Modal form keydown listener
$ ( document ) . on ( "keydown" , PF . obj . modal . selectors . root + " input" , function ( e ) { // nota: solia ser keyup
var $this = $ ( e . target ) ,
key = e . charCode || e . keyCode ;
if ( key !== 13 ) {
PF . fn . growl . close ( ) ;
return ;
}
if ( key == 13 && $ ( "[data-action=submit]" , PF . obj . modal . selectors . root ) . exists ( ) && ! $this . is ( ".prevent-submit" ) ) { // 13 == enter key
$ ( "[data-action=submit]" , PF . obj . modal . selectors . root ) . click ( ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Trigger modal edit on hash #edit
// It must be placed after the event listener
if ( window . location . hash && window . location . hash == "#edit" ) {
$ ( "[data-modal=edit]" ) . first ( ) . click ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* MOBILE TOP BAR MENU
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
$ ( document ) . on ( "click" , "[data-action=top-bar-menu-full]" , function ( ) {
var hasClass = $ ( '[data-action=top-bar-menu-full]' , "#top-bar" ) . hasClass ( "current" ) ;
PF . fn . topMenu [ hasClass ? "hide" : "show" ] ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* SEARCH INPUT
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Top-search feature
$ ( document ) . on ( "click" , "[data-action=top-bar-search]" , function ( ) {
$ ( "[data-action=top-bar-search-input]" , ".top-bar" ) . removeClass ( "hidden" ) . show ( ) ;
$ ( "[data-action=top-bar-search-input]:visible input" ) . first ( ) . focus ( ) ;
if ( is _ios ( ) && ! $ ( this ) . closest ( PF . fn . topMenu . vars . menu ) . exists ( ) ) {
$ ( '.top-bar' ) . css ( 'position' , 'absolute' ) ;
}
$ ( "[data-action=top-bar-search]" , ".top-bar" ) . hide ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Search icon click -> focus input
$ ( document ) . on ( "click" , ".input-search .icon-search" , function ( e ) {
$ ( "input" , e . currentTarget . offsetParent ) . focus ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Clean search input
$ ( document ) . on ( "click" , ".input-search .icon-close, .input-search [data-action=clear-search]" , function ( e ) {
var $input = $ ( "input" , e . currentTarget . offsetParent ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $input . val ( ) == "" ) {
if ( $ ( this ) . closest ( "[data-action=top-bar-search-input]" ) . exists ( ) ) {
$ ( "[data-action=top-bar-search-input]" , ".top-bar" ) . hide ( ) ;
$ ( "[data-action=top-bar-search]" , ".top-bar" ) . removeClass ( "opened" ) . show ( ) ;
if ( is _ios ( ) && $ ( this ) . closest ( "#top-bar" ) . css ( "position" ) !== "fixed" ) {
2016-11-06 02:19:47 +00:00
$ ( ".top-bar" ) . css ( "position" , "fixed" ) ;
2016-08-18 20:39:31 +00:00
}
}
} else {
if ( ! $ ( this ) . closest ( "[data-action=top-bar-search-input]" ) . exists ( ) ) {
$ ( this ) . hide ( ) ;
}
$input . val ( "" ) . change ( ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Input search clear search toggle
$ ( document ) . on ( "keyup change" , "input.search" , function ( e ) {
var $input = $ ( this ) ,
$div = $ ( this ) . closest ( ".input-search" ) ;
if ( ! $ ( this ) . closest ( "[data-action=top-bar-search-input]" ) . exists ( ) ) {
var todo = $input . val ( ) == "" ? "hide" : "show" ;
$ ( ".icon-close, [data-action=clear-search]" , $div ) [ todo ] ( ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* POP BOXES ( MENUS )
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
$ ( document ) . on ( "click mouseenter" , ".pop-btn" , function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . fn . isDevice ( [ "phone" , "phablet" ] ) && ( e . type == "mouseenter" || $ ( this ) . hasClass ( "pop-btn-desktop" ) ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
var $this _click = $ ( e . target ) ;
var $pop _btn ;
var $pop _box ;
var devices = $ . makeArray ( [ "phone" , "phablet" ] ) ;
var $this = $ ( this ) ;
2016-08-18 20:39:31 +00:00
if ( e . type == "mouseenter" && ! $ ( this ) . hasClass ( "pop-btn-auto" ) ) return ;
if ( $ ( this ) . hasClass ( "disabled" ) || ( ( $this _click . closest ( ".current" ) . exists ( ) && ! PF . fn . isDevice ( "phone" ) ) && ! $this _click . closest ( ".pop-btn-show" ) . exists ( ) ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . growl . close ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
e . stopPropagation ( ) ;
2018-04-17 21:25:26 +00:00
$pop _btn = $ ( this ) ;
2016-08-18 20:39:31 +00:00
$pop _box = $ ( ".pop-box" , $pop _btn ) ;
$pop _btn . addClass ( "opened" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".pop-box-inner" , $pop _box ) . css ( "max-height" , "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . fn . isDevice ( devices ) ) {
var text = $ ( '.btn-text,.text,.pop-btn-text' , $pop _btn ) . first ( ) . text ( ) ;
if ( typeof text == "undefined" || text == "" ) {
text = PF . fn . _s ( "Select" ) ;
}
if ( ! $ ( ".pop-box-header" , $pop _box ) . exists ( ) ) {
$pop _box . prepend ( $ ( '<div/>' , {
"class" : 'pop-box-header' ,
"html" : text + '<span class="btn-icon icon-close"></span></span>'
} ) ) ;
}
} else {
$ ( '.pop-box-header' , $pop _box ) . remove ( ) ;
$pop _box . css ( { bottom : '' } ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $pop _box . hasClass ( "anchor-center" ) ) {
if ( ! PF . fn . isDevice ( devices ) ) {
$pop _box . css ( "margin-left" , - ( $pop _box . width ( ) / 2 ) ) ;
} else {
$pop _box . css ( "margin-left" , "" ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Pop button changer
if ( $this _click . is ( "[data-change]" ) ) {
$ ( "li" , $pop _box ) . removeClass ( "current" ) ;
$this _click . closest ( "li" ) . addClass ( "current" ) ;
$ ( "[data-text-change]" , $pop _btn ) . text ( $ ( "li.current a" , $pop _box ) . text ( ) ) ;
e . preventDefault ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $pop _box . exists ( ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Click inside the bubble only for .pop-keep-click
var $this = e . istriggered ? $ ( e . target ) : $ ( this ) ;
if ( $pop _box . is ( ":visible" ) && $ ( e . target ) . closest ( ".pop-box-inner" ) . exists ( ) && $this . hasClass ( "pop-keep-click" ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".pop-box:visible" ) . not ( $pop _box ) . hide ( ) . closest ( ".pop-btn" ) . removeClass ( "opened" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var callback = function ( $pop _box ) {
2018-04-17 21:25:26 +00:00
if ( ! $pop _box . is ( ":visible" ) ) {
var guidstr = $pop _box . attr ( "data-guidstr" ) ;
$pop _box
. css ( "marginLeft" , "" )
. removeClass ( guidstr )
. removeAttr ( "data-guidstr" )
. closest ( ".pop-btn" )
. removeClass ( "opened" ) ;
if ( typeof guidstr !== typeof undefined ) {
$ ( "style#" + guidstr ) . remove ( ) ;
}
2016-08-18 20:39:31 +00:00
} else {
if ( ! PF . fn . isDevice ( devices ) ) {
2018-04-17 21:25:26 +00:00
var posMargin = $pop _box . css ( "marginLeft" ) ;
if ( typeof posMargin !== typeof undefined ) {
posMargin = parseFloat ( posMargin ) ;
$pop _box . css ( "marginLeft" , "" ) ;
}
var cutoff = $pop _box . getWindowCutoff ( ) ;
if ( ( cutoff && ( cutoff . left || cutoff . right ) ) && cutoff . right < posMargin ) {
var guidstr = "guid-" + PF . fn . guid ( ) ;
$pop _box . css ( "marginLeft" , cutoff . right + "px" ) . addClass ( guidstr ) . attr ( "data-guidstr" , guidstr ) ;
var posArrow = $this . outerWidth ( ) / 2 + $this . offset ( ) . left - $pop _box . offset ( ) . left ;
var selectors = [ ] ;
$ . each ( [ "top" , "bottom" ] , function ( i , v ) {
$ . each ( [ "after" , "before" ] , function ( ii , vv ) {
selectors . push ( '.' + guidstr + '.arrow-box-' + v + ':' + vv ) ;
} )
} ) ;
$ ( '<style id="' + guidstr + '">' + selectors . join ( ) + ' { left: ' + posArrow + 'px; }</style>' ) . appendTo ( "head" ) ;
} else {
$pop _box . css ( "marginLeft" , posMargin + "px" ) ;
}
2016-08-18 20:39:31 +00:00
$ ( ".antiscroll-wrap:not(.jsly):visible" , $pop _box ) . addClass ( "jsly" ) . antiscroll ( ) ;
} else {
$ ( ".antiscroll-inner" , $pop _box ) . height ( "100%" ) ;
}
}
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . fn . isDevice ( devices ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . is ( "[data-action=top-bar-notifications]" ) ) {
$pop _box . css ( { height : $ ( window ) . height ( ) } ) ;
}
var pop _box _h = $pop _box . height ( ) + 'px' ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var menu _top = ( parseInt ( $ ( ".top-bar" ) . outerHeight ( ) ) + parseInt ( $ ( ".top-bar" ) . css ( "top" ) ) + parseInt ( $ ( ".top-bar" ) . css ( "margin-top" ) ) + parseInt ( $ ( ".top-bar" ) . css ( "margin-bottom" ) ) ) + "px" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// hide
if ( $pop _box . is ( ":visible" ) ) {
$ ( '#pop-box-mask' ) . css ( { opacity : 0 } ) ;
$pop _box . css ( { transform : "none" } ) ;
if ( $this . closest ( PF . fn . topMenu . vars . menu ) . exists ( ) ) {
$ ( ".top-bar" ) . css ( { transform : "none" } ) ;
$ ( PF . fn . topMenu . vars . menu ) . css ( {
height : $ ( window ) . height ( ) + parseInt ( menu _top ) ,
} ) ;
}
setTimeout ( function ( ) {
$pop _box . hide ( ) . attr ( "style" , "" ) ;
$ ( '#pop-box-mask' ) . remove ( ) ;
callback ( $pop _box ) ;
if ( $this . closest ( PF . fn . topMenu . vars . menu ) . exists ( ) ) {
$ ( PF . fn . topMenu . vars . menu ) . css ( {
height : "" ,
} ) ;
$ ( PF . fn . topMenu . vars . menu ) . animate ( { scrollTop : PF . fn . topMenu . vars . scrollTop } , PF . obj . config . animation . normal / 2 ) ;
}
} , PF . obj . config . animation . normal ) ;
if ( ! $ ( "body" ) . data ( "hasOverflowHidden" ) ) {
$ ( "body" ) . removeClass ( "overflow-hidden" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} else { // show
$ ( '#pop-box-mask' ) . remove ( ) ;
$pop _box . parent ( ) . prepend ( $ ( '<div/>' , {
"id" : 'pop-box-mask' ,
"class" : 'fullscreen soft-black'
} ) . css ( {
zIndex : 400 ,
display : "block"
} ) ) ;
PF . fn . topMenu . vars . scrollTop = $ ( PF . fn . topMenu . vars . menu ) . scrollTop ( ) ;
setTimeout ( function ( ) {
$ ( "#pop-box-mask" ) . css ( { opacity : 1 } ) ;
setTimeout ( function ( ) {
$pop _box . show ( ) . css ( {
bottom : '-' + pop _box _h ,
maxHeight : $ ( window ) . height ( ) ,
zIndex : 1000 ,
transform : "translate(0,-" + pop _box _h + ")"
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
setTimeout ( function ( ) {
callback ( $pop _box ) ;
} , PF . obj . config . animation . normal ) ;
if ( $ ( "body" ) . hasClass ( "overflow-hidden" ) ) {
$ ( "body" ) . data ( "hasOverflowHidden" , 1 ) ;
} else {
$ ( "body" ) . addClass ( "overflow-hidden" ) ;
}
if ( $this . closest ( PF . fn . topMenu . vars . menu ) . exists ( ) ) {
$ ( ".top-bar" ) . css ( { transform : "translate(0, -" + menu _top + ")" } ) ;
$ ( PF . fn . topMenu . vars . menu ) . css ( {
height : $ ( window ) . height ( ) + parseInt ( menu _top ) ,
} ) ;
}
$ ( ".pop-box-inner" , $pop _box ) . css ( "height" , $pop _box . height ( ) - $ ( '.pop-box-header' , $pop _box ) . outerHeight ( true ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} , 1 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} , 1 ) ;
}
} else {
2018-04-17 21:25:26 +00:00
$pop _box [ ( $pop _box . is ( ":visible" ) ? "hide" : "show" ) ] ( 0 , function ( ) {
2016-08-18 20:39:31 +00:00
callback ( $pop _box ) ;
} ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) . on ( "mouseleave" , ".pop-btn" , function ( ) {
if ( ! PF . fn . isDevice ( [ "laptop" , "desktop" ] ) ) {
return ;
}
var $pop _btn = $ ( this ) ,
$pop _box = $ ( ".pop-box" , $pop _btn ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $pop _btn . hasClass ( "pop-btn-auto" ) || ( PF . fn . isDevice ( [ "phone" , "phablet" ] ) && $pop _btn . hasClass ( "pop-btn-auto" ) ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! PF . fn . isDevice ( [ 'phone' , 'phablet' , 'tablet' ] ) && $ ( this ) . hasClass ( "pop-btn-delayed" ) ) {
$ ( this ) . removeClass ( "pop-btn-auto" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$pop _box . hide ( ) . closest ( ".pop-btn" ) . removeClass ( "opened" ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".pop-btn-delayed" ) . delayedAction (
{
delayedAction : function ( $element ) {
if ( PF . fn . isDevice ( [ 'phone' , 'phablet' , 'tablet' ] ) ) return ;
var $el = $ ( ".pop-box-inner" , $element ) ;
if ( $el . is ( ":hidden" ) ) {
$element . addClass ( "pop-btn-auto" ) . click ( ) ;
}
} ,
hoverTime : 2000
}
) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* TABS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Hash on load (static tabs) changer
if ( window . location . hash ) {
/ *
var $hash _node = $ ( "[href=" + window . location . hash + "]" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $hash _node . exists ( ) ) {
$ . each ( $ ( "[href=" + window . location . hash + "]" ) [ 0 ] . attributes , function ( ) {
PF . obj . tabs . hashdata [ this . name ] = this . value ;
} ) ;
PF . obj . tabs . hashdata . pushed = "tabs" ;
History . replaceState ( {
href : window . location . hash ,
"data-tab" : $ ( "[href=" + window . location . hash + "]" ) . data ( "tab" ) ,
pushed : "tabs" ,
statenum : 0
} , null , null ) ;
}
* /
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock tab onload data
if ( $ ( ".content-tabs" ) . exists ( ) /* && !window.location.hash*/ ) {
var $tab = $ ( "a" , ".content-tabs .current" ) ;
History . replaceState ( {
href : $tab . attr ( "href" ) ,
"data-tab" : $tab . data ( "tab" ) ,
pushed : "tabs" ,
statenum : 0
} , null , null ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Keep scroll position (history.js)
var State = History . getState ( ) ;
if ( typeof State . data == "undefined" ) {
History . replaceState ( { scrollTop : 0 } , document . title , window . location . href ) ; // Stock initial scroll
}
History . Adapter . bind ( window , "popstate" , function ( ) {
var State = History . getState ( ) ;
if ( State . data && typeof State . data . scrollTop !== "undefined" ) {
if ( $ ( window ) . scrollTop ( ) !== State . data . scrollTop ) {
$ ( window ) . scrollTop ( State . data . scrollTop ) ;
}
}
return ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Toggle tab display
$ ( "a" , ".content-tabs" ) . click ( function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . data ( "link" ) == true ) {
$ ( this ) . data ( "tab" , false ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . closest ( ".current,.disabled" ) . exists ( ) ) {
e . preventDefault ( ) ;
return ;
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
if ( typeof $ ( this ) . data ( "tab" ) == "undefined" ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var dataTab = { } ;
$ . each ( this . attributes , function ( ) {
dataTab [ this . name ] = this . value ;
} ) ;
dataTab . pushed = "tabs" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// This helps to avoid issues on ?same and ?same#else
/ * d a t a T a b . s t a t e n u m = 0 ;
console . log ( {
data : History . getState ( ) . data ,
state : History . getState ( ) . data . statenum
} )
if ( History . getState ( ) . data && typeof History . getState ( ) . data . statenum !== "undefined" ) {
dataTab . statenum = History . getState ( ) . data . statenum + 1
} * /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/*if($(this).attr("href") && $(this).attr("href").indexOf("#") === 0) { / / to - > # Hash
PF . obj . tabs . hashdata = dataTab ;
if ( typeof e . originalEvent == "undefined" ) {
window . location . hash = PF . obj . tabs . hashdata . href . substring ( 1 ) ;
}
} else { // to ->?anything
if ( $ ( "#" + dataTab [ "data-tab" ] ) . data ( "load" ) != "classic" ) {
History . pushState ( dataTab , document . title , $ ( this ) . attr ( "href" ) ) ;
e . preventDefault ( ) ;
}
}
* /
if ( $ ( "#" + dataTab [ "data-tab" ] ) . data ( "load" ) != "classic" ) {
if ( window . location . hash ) {
var url = window . location . href ;
url = url . replace ( window . location . hash , "" ) ;
}
History . pushState ( dataTab , document . title , ( typeof url !== "undefined" ) ? url : $ ( this ) . attr ( "href" ) ) ;
e . preventDefault ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $tab _menu = $ ( "[data-action=tab-menu]" , $ ( this ) . closest ( ".header" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$tab _menu . find ( "[data-content=current-tab-label]" ) . text ( $ ( this ) . text ( ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $tab _menu . is ( ":visible" ) ) {
$tab _menu . click ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( document ) . on ( "click" , "[data-action=tab-menu]" , function ( ) {
var $tabs = $ ( this ) . closest ( ".header" ) . find ( ".content-tabs" ) ,
visible = $tabs . is ( ":visible" ) ,
$this = $ ( this ) ;
if ( ! visible ) {
$tabs . data ( "classes" , $tabs . attr ( "class" ) ) ;
$tabs . removeClass ( function ( index , css ) {
return ( css . match ( /\b\w+-hide/g ) || [ ] ) . join ( ' ' ) ;
} ) ;
$tabs . hide ( ) ;
}
if ( ! visible ) {
$this . removeClass ( "current" ) ;
}
$tabs [ visible ? "hide" : "show" ] ( ) ;
if ( visible ) {
$tabs . css ( "display" , "" ) . addClass ( $tabs . data ( "classes" ) ) ;
$this . addClass ( "current" ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// On state change bind tab changes
$ ( window ) . bind ( "statechange" , function ( e ) {
PF . fn . growl . close ( ) ;
var dataTab ;
2018-04-17 21:25:26 +00:00
dataTab = History . getState ( ) . data ;
2016-08-18 20:39:31 +00:00
if ( dataTab && dataTab . pushed == "tabs" ) {
PF . fn . show _tab ( dataTab [ "data-tab" ] ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* LISTING
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock the scroll position on list element click
$ ( document ) . on ( "click" , ".list-item a" , function ( e ) {
if ( $ ( this ) . attr ( "src" ) == "" ) return ;
History . replaceState ( { scrollTop : $ ( window ) . scrollTop ( ) } , document . title , window . location . href ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Load more (listing +1 page)
$ ( document ) . on ( "click" , "[data-action=load-more]" , function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . closest ( '.content-listing-more' ) . hide ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! PF . fn . is _listing ( ) || $ ( this ) . closest ( PF . obj . listing . selectors . content _listing ) . is ( ":hidden" ) || $ ( this ) . closest ( "#content-listing-template" ) . exists ( ) || PF . obj . listing . calling ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . listing . queryString . stock _new ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Page hack
PF . obj . listing . query _string . page = $ ( PF . obj . listing . selectors . content _listing _visible ) . data ( "page" ) ;
PF . obj . listing . query _string . page ++ ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Offset hack
var offset = $ ( PF . obj . listing . selectors . content _listing _visible ) . data ( "offset" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof offset !== "undefined" ) {
PF . obj . listing . query _string . offset = offset ;
2017-11-09 19:02:18 +00:00
if ( typeof PF . obj . listing . params _hidden == "undefined" ) {
PF . obj . listing . params _hidden = { } ;
2016-08-18 20:39:31 +00:00
}
2017-11-09 19:02:18 +00:00
PF . obj . listing . params _hidden . offset = offset ;
2016-08-18 20:39:31 +00:00
} else {
if ( typeof PF . obj . listing . query _string . offset !== "undefined" ) {
delete PF . obj . listing . query _string . offset ;
}
2017-11-09 19:02:18 +00:00
if ( PF . obj . listing . params _hidden && typeof PF . obj . listing . params _hidden . offset !== "undefined" ) {
delete PF . obj . listing . params _hidden . offset ;
2016-08-18 20:39:31 +00:00
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . listing . ajax ( ) ;
e . preventDefault ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// List found on load html -> Do the columns!
if ( $ ( PF . obj . listing . selectors . list _item ) . length > 0 ) {
PF . fn . listing . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Bind the infinte scroll
$ ( window ) . scroll ( function ( ) {
var $loadMore = $ ( PF . obj . listing . selectors . content _listing _pagination , PF . obj . listing . selectors . content _listing _visible ) . find ( "[data-action=load-more]" ) ;
if ( $loadMore . length > 0 && ( ( $ ( window ) . scrollTop ( ) + $ ( window ) . innerHeight ( ) ) > ( $ ( document ) . height ( ) - 300 ) ) && PF . obj . listing . calling == false ) {
$loadMore . click ( ) ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Multi-selection tools
$ ( document ) . on ( "click" , PF . obj . modal . selectors . root + " [data-switch]" , function ( ) {
var $this _modal = $ ( this ) . closest ( PF . obj . modal . selectors . root ) ;
$ ( "[data-view=switchable]" , $this _modal ) . hide ( ) ;
$ ( "#" + $ ( this ) . attr ( "data-switch" ) , $this _modal ) . show ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( document ) . on ( "click" , "[data-toggle]" , function ( ) {
2018-04-17 21:25:26 +00:00
var $target = $ ( "[data-content=" + $ ( this ) . data ( "toggle" ) + "]" ) ;
var show = ! $target . is ( ":visible" ) ;
2016-08-18 20:39:31 +00:00
$ ( this ) . html ( $ ( this ) . data ( 'html-' + ( show ? 'on' : 'off' ) ) ) ;
$target . toggle ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Cookie law thing
$ ( document ) . on ( "click" , "[data-action=cookie-law-close]" , function ( ) {
2018-04-17 21:25:26 +00:00
var $cookie = $ ( this ) . closest ( "#cookie-law-banner" ) ;
var cookieName = ( typeof $cookie . data ( "cookie" ) !== typeof undefined ) ? $cookie . data ( "cookie" ) : "PF_COOKIE_LAW_DISPLAY" ;
Cookies . set ( cookieName , 0 , { expires : 365 } ) ;
$cookie . remove ( ) ;
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// One-click input copy
Clipboard = new Clipboard ( "[data-action=copy]" , {
text : function ( trigger ) {
var $target = $ ( trigger . getAttribute ( "data-action-target" ) ) ;
var text = $target . is ( ":input" ) ? $target . val ( ) : $target . text ( ) ;
return text . trim ( ) ;
}
} ) ;
Clipboard . on ( 'success' , function ( e ) {
var $target = $ ( e . trigger . getAttribute ( "data-action-target" ) ) ;
$target . highlight ( ) ;
e . clearSelection ( ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
/ * *
* PEAFOWL OBJECT
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
var PF = { fn : { } , str : { } , obj : { } } ;
/ * *
* PEAFOWL CONFIG
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . obj . config = {
base _url : "" ,
json _api : "/json/" ,
listing : {
items _per _page : 24
} ,
animation : {
easingFn : "ease" ,
normal : 400 ,
fast : 250
}
} ;
/ * *
* WINDOW VARS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
/ * *
* LANGUAGE FUNCTIONS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . obj . l10n = { } ;
/ * *
* Get lang string by key
* @ argument string ( lang key string )
* /
// pf: get_pf_lang
PF . fn . _s = function ( string , s ) {
var string ;
if ( typeof string == "undefined" ) {
return string ;
}
if ( typeof PF . obj . l10n !== "undefined" && typeof PF . obj . l10n [ string ] !== "undefined" ) {
string = PF . obj . l10n [ string ] [ 0 ] ;
if ( typeof string == "undefined" ) {
string = string ;
}
} else {
string = string ;
}
string = string . toString ( ) ;
if ( typeof s !== "undefined" ) {
string = sprintf ( string , s ) ;
}
return string ;
} ;
PF . fn . _n = function ( singular , plural , n ) {
var string ;
if ( typeof PF . obj . l10n !== "undefined" && typeof PF . obj . l10n [ singular ] !== "undefined" ) {
string = PF . obj . l10n [ singular ] [ n == 1 ? 0 : 1 ] ;
} else {
string = n == 1 ? singular : plural ;
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
string = typeof string == "undefined" ? singular : string . toString ( ) ;
if ( typeof n !== "undefined" ) {
string = sprintf ( string , n ) ;
}
return string ;
} ;
/ * *
* Extend Peafowl lang
* Useful to add or replace strings
* @ argument strings obj
* /
// pf: extend_pf_lang
PF . fn . extend _lang = function ( strings ) {
$ . each ( PF . obj . lang _strings , function ( i , v ) {
if ( typeof strings [ i ] !== "undefined" ) {
$ . extend ( PF . obj . lang _strings [ i ] , strings [ i ] ) ;
}
} ) ;
} ;
/ * *
* HELPER FUNCTIONS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . fn . get _url _vars = function ( ) {
var match ,
pl = /\+/g , // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g ,
decode = function ( s ) {
return decodeURIComponent ( escape ( s . replace ( pl , " " ) ) ) ;
} ,
query = window . location . search . substring ( 1 ) ,
urlParams = { } ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
while ( match = search . exec ( query ) ) {
urlParams [ decode ( match [ 1 ] ) ] = decode ( match [ 2 ] ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
return urlParams ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ;
PF . fn . get _url _var = function ( name ) {
return PF . fn . get _url _vars ( ) [ name ] ;
} ;
PF . fn . is _user _logged = function ( ) {
2017-11-09 19:02:18 +00:00
return $ ( "#top-bar-user" ) . exists ( ) ; // nota: default version
2016-08-18 20:39:31 +00:00
// It should use backend conditional
} ;
PF . fn . generate _random _string = function ( len ) {
if ( typeof len == "undefined" ) len = 5 ;
var text = "" ;
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ;
for ( var i = 0 ; i < len ; i ++ ) {
text += possible . charAt ( Math . floor ( Math . random ( ) * possible . length ) ) ;
}
return text ;
} ;
PF . fn . getDateTime = function ( ) {
2018-04-17 21:25:26 +00:00
var now = new Date ( ) ;
2016-08-18 20:39:31 +00:00
var year = now . getFullYear ( ) ;
2018-04-17 21:25:26 +00:00
var month = now . getMonth ( ) + 1 ;
2016-08-18 20:39:31 +00:00
var day = now . getDate ( ) ;
var hour = now . getHours ( ) ;
var minute = now . getMinutes ( ) ;
2018-04-17 21:25:26 +00:00
var second = now . getSeconds ( ) ;
2016-08-18 20:39:31 +00:00
if ( month . toString ( ) . length == 1 ) {
var month = '0' + month ;
}
if ( day . toString ( ) . length == 1 ) {
var day = '0' + day ;
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
if ( hour . toString ( ) . length == 1 ) {
var hour = '0' + hour ;
}
if ( minute . toString ( ) . length == 1 ) {
var minute = '0' + minute ;
}
if ( second . toString ( ) . length == 1 ) {
var second = '0' + second ;
2018-04-17 21:25:26 +00:00
}
var dateTime = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second ;
2016-08-18 20:39:31 +00:00
return dateTime ;
} ;
PF . fn . htmlEncode = function ( value ) {
return $ ( '<div/>' ) . text ( $ . trim ( value ) ) . html ( ) ;
} ;
PF . fn . htmlDecode = function ( value ) {
return $ ( '<div/>' ) . html ( $ . trim ( value ) ) . text ( ) ;
} ;
2018-04-17 21:25:26 +00:00
PF . fn . nl2br = function ( str ) {
var breakTag = '<br>' ;
2016-08-18 20:39:31 +00:00
return ( str + '' ) . replace ( /([^>\r\n]?)(\r\n|\n\r|\r|\n)/g , '$1' + breakTag + '$2' ) ;
} ;
// https://gist.github.com/alexey-bass/1115557
PF . fn . versionCompare = function ( left , right ) {
if ( typeof left + typeof right != 'stringstring' )
return false ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var a = left . split ( '.' )
, b = right . split ( '.' )
, i = 0 , len = Math . max ( a . length , b . length ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( ; i < len ; i ++ ) {
if ( ( a [ i ] && ! b [ i ] && parseInt ( a [ i ] ) > 0 ) || ( parseInt ( a [ i ] ) > parseInt ( b [ i ] ) ) ) {
return 1 ;
} else if ( ( b [ i ] && ! a [ i ] && parseInt ( b [ i ] ) > 0 ) || ( parseInt ( a [ i ] ) < parseInt ( b [ i ] ) ) ) {
return - 1 ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
return 0 ;
}
/ * *
* Basename
* http : //stackoverflow.com/questions/3820381/need-a-basename-function-in-javascript
* /
PF . fn . baseName = function ( str ) {
2018-04-17 21:25:26 +00:00
var base = new String ( str ) . substring ( str . lastIndexOf ( '/' ) + 1 ) ;
if ( base . lastIndexOf ( "." ) != - 1 ) {
2016-08-18 20:39:31 +00:00
base = base . substring ( 0 , base . lastIndexOf ( "." ) ) ;
}
return base ;
}
2018-04-17 21:25:26 +00:00
// https://stackoverflow.com/a/8809472
2016-08-18 20:39:31 +00:00
PF . fn . guid = function ( ) {
2018-04-17 21:25:26 +00:00
var d = new Date ( ) . getTime ( ) ;
if ( typeof performance !== 'undefined' && typeof performance . now === 'function' ) {
d += performance . now ( ) ; //use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( /[xy]/g , function ( c ) {
var r = ( d + Math . random ( ) * 16 ) % 16 | 0 ;
d = Math . floor ( d / 16 ) ;
return ( c === 'x' ? r : ( r & 0x3 | 0x8 ) ) . toString ( 16 ) ;
} ) ;
2016-08-18 20:39:31 +00:00
}
PF . fn . md5 = function ( string ) {
return SparkMD5 . hash ( string ) ;
}
/ * *
* dataURI to BLOB
* http : //stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata
* /
PF . fn . dataURItoBlob = function ( dataURI ) {
// convert base64/URLEncoded data component to raw binary data held in a string
var byteString ;
if ( dataURI . split ( ',' ) [ 0 ] . indexOf ( 'base64' ) >= 0 ) {
byteString = atob ( dataURI . split ( ',' ) [ 1 ] ) ;
} else {
byteString = unescape ( dataURI . split ( ',' ) [ 1 ] ) ;
}
// separate out the mime component
var mimeString = dataURI . split ( ',' ) [ 0 ] . split ( ':' ) [ 1 ] . split ( ';' ) [ 0 ] ;
// write the bytes of the string to a typed array
var ia = new Uint8Array ( byteString . length ) ;
for ( var i = 0 ; i < byteString . length ; i ++ ) {
ia [ i ] = byteString . charCodeAt ( i ) ;
}
return new Blob ( [ ia ] , { type : mimeString } ) ;
}
PF . fn . clean _facebook _hash = function ( ) {
if ( window . location . hash == "#_=_" ) {
window . location . hash = "" ;
}
} ;
PF . fn . clean _facebook _hash ( ) ;
/ * *
* Get the min and max value from 1 D array
* /
Array . min = function ( array ) {
return Math . min . apply ( Math , array ) ;
} ;
Array . max = function ( array ) {
return Math . max . apply ( Math , array ) ;
} ;
/ * *
* Return the sum of all the values in a 1 D array
* /
Array . sum = function ( array ) {
return array . reduce ( function ( pv , cv ) { return cv + pv } ) ;
} ;
/ * *
* Return the size of an object
* /
Object . size = function ( obj ) {
var size = 0 , key ;
for ( key in obj ) {
if ( obj . hasOwnProperty ( key ) ) size ++ ;
}
return size ;
} ;
/ * *
* Flatten an object
* /
Object . flatten = function ( obj , prefix ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof prefix == "undefined" ) var prefix = "" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var result = { } ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ . each ( obj , function ( key , value ) {
if ( ! value ) return ;
if ( typeof value == "object" ) {
result = $ . extend ( { } , result , Object . flatten ( value , prefix + key + '_' ) ) ;
} else {
result [ prefix + key ] = value ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
return result ;
} ;
/ * *
* Tells if the string is a number or not
* /
String . prototype . isNumeric = function ( ) {
return ! isNaN ( parseFloat ( this ) ) && isFinite ( this ) ;
} ;
/ * *
* Repeats an string
* /
String . prototype . repeat = function ( num ) {
return new Array ( num + 1 ) . join ( this ) ;
} ;
/ * *
* Ucfirst
* /
String . prototype . capitalizeFirstLetter = function ( ) {
return this . charAt ( 0 ) . toUpperCase ( ) + this . slice ( 1 ) ;
}
/ * *
* Tells if the string is a email or not
* /
String . prototype . isEmail = function ( ) {
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/ ;
return regex . test ( this ) ;
} ;
// http://phpjs.org/functions/round/
String . prototype . getRounded = function ( precision , mode ) {
var m , f , isHalf , sgn ; // helper variables
precision |= 0 ; // making sure precision is integer
m = Math . pow ( 10 , precision ) ;
value = this ;
value *= m ;
sgn = ( value > 0 ) | - ( value < 0 ) ; // sign of the number
isHalf = value % 1 === 0.5 * sgn ;
f = Math . floor ( value ) ;
if ( isHalf ) {
switch ( mode ) {
case 'PHP_ROUND_HALF_DOWN' :
value = f + ( sgn < 0 ) ; // rounds .5 toward zero
break ;
case 'PHP_ROUND_HALF_EVEN' :
value = f + ( f % 2 * sgn ) ; // rouds .5 towards the next even integer
break ;
case 'PHP_ROUND_HALF_ODD' :
value = f + ! ( f % 2 ) ; // rounds .5 towards the next odd integer
break ;
default :
value = f + ( sgn > 0 ) ; // rounds .5 away from zero
}
}
return ( isHalf ? value : Math . round ( value ) ) / m ;
} ;
/ * *
* Return bytes from Size + Suffix like "10 MB"
* /
String . prototype . getBytes = function ( ) {
var units = [ "KB" , "MB" , "GB" , "TB" , "PB" , "EB" , "ZB" , "YB" ] ,
suffix = this . toUpperCase ( ) . substr ( - 2 ) ;
if ( units . indexOf ( suffix ) == - 1 ) {
return this ;
}
var pow _factor = units . indexOf ( suffix ) + 1 ;
return parseFloat ( this ) * Math . pow ( 1000 , pow _factor ) ;
} ;
/ * *
* Return size formatted from size bytes
* /
String . prototype . formatBytes = function ( round ) {
var bytes = parseInt ( this ) ,
units = [ "KB" , "MB" , "GB" , "TB" , "PB" , "EB" , "ZB" , "YB" ] ;
if ( ! $ . isNumeric ( this ) ) {
return false ;
}
if ( bytes < 1000 ) return bytes + " B" ;
if ( typeof round == "undefined" ) var round = 2 ;
for ( var i = 0 ; i < units . length ; i ++ ) {
var multiplier = Math . pow ( 1000 , i + 1 ) ,
threshold = multiplier * 1000 ;
if ( bytes < threshold ) {
var size = bytes / multiplier ;
return this . getRounded . call ( size , round ) + " " + units [ i ] ;
}
}
} ;
/ * *
* Returns the image url . matches ( multiple )
* /
String . prototype . match _image _urls = function ( ) {
2016-10-12 16:32:18 +00:00
return this . match ( /\b(?:(http[s]?|ftp[s]):\/\/)?([^:\/\s]+)(:[0-9]+)?((?:\/\w+)*\/)([\w\-\.]+[^#?\s]+)([^#\s]*)?(#[\w\-]+)?\.(?:jpe?g|gif|png|bmp)\b/gim ) ;
2016-08-18 20:39:31 +00:00
} ;
String . prototype . match _urls = function ( ) {
return this . match ( /\b(?:(http[s]?|ftp[s]):\/\/)?([^:\/\s]+)(:[0-9]+)?((?:\/\w+)*\/)([\w\-\.]+[^#?\s]+)([^#\s]*)?(#[\w\-]+)?\b/gim ) ;
} ;
// Add ECMA262-5 Array methods if not supported natively
if ( ! ( "indexOf" in Array . prototype ) ) {
Array . prototype . indexOf = function ( find , i /*opt*/ ) {
if ( i === undefined ) i = 0 ;
if ( i < 0 ) i += this . length ;
if ( i < 0 ) i = 0 ;
for ( var n = this . length ; i < n ; i ++ ) {
if ( i in this && this [ i ] === find ) {
return i ;
}
}
return - 1 ;
} ;
}
/ * *
* Removes all the array duplicates without loosing the array order .
* /
Array . prototype . array _unique = function ( ) {
var result = [ ] ;
$ . each ( this , function ( i , e ) {
if ( $ . inArray ( e , result ) == - 1 ) result . push ( e ) ;
} ) ;
return result ;
} ;
PF . fn . deparam = function ( querystring ) {
if ( typeof querystring == "undefined" || ! querystring ) return ;
var obj = { } ,
pairs = querystring . replace ( /^[\?|&]*/ , "" ) . replace ( /[&|\?]*$/ , "" ) . split ( "&" ) ;
for ( var i = 0 ; i < pairs . length ; i ++ ) {
var split = pairs [ i ] . split ( '=' ) ;
var key = decodeURIComponent ( split [ 0 ] ) ;
var value = decodeURIComponent ( split [ 1 ] ) ;
// Aready in the object?
if ( obj . hasOwnProperty ( key ) && ! value ) {
continue ;
}
obj [ key ] = value ;
}
return obj ;
} ;
// http://stackoverflow.com/a/1634841/1145912
String . prototype . removeURLParameter = function ( key ) {
var url = "" ,
deparam = PF . fn . deparam ( this ) ;
if ( typeof deparam [ key ] !== "undefined" ) {
delete deparam [ key ] ;
}
return decodeURIComponent ( $ . param ( deparam ) ) ;
} ;
/ * *
* Truncate the middle of the URL just like Firebug
* From http : //stackoverflow.com/questions/10903002/shorten-url-for-display-with-beginning-and-end-preserved-firebug-net-panel-st
* /
String . prototype . truncate _middle = function ( l ) {
var l = typeof ( l ) != "undefined" ? l : 40 ,
chunk _l = ( l / 2 ) ,
url = this . replace ( /https?:\/\//g , "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( url . length <= l ) {
return url ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
function shortString ( s , l , reverse ) {
var stop _chars = [ ' ' , '/' , '&' ] ,
acceptable _shortness = l * 0.80 , // When to start looking for stop characters
reverse = typeof ( reverse ) != "undefined" ? reverse : false ,
s = reverse ? s . split ( "" ) . reverse ( ) . join ( "" ) : s ,
short _s = "" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( var i = 0 ; i < l - 1 ; i ++ ) {
short _s += s [ i ] ;
if ( i >= acceptable _shortness && stop _chars . indexOf ( s [ i ] ) >= 0 ) {
break ;
}
} ;
if ( reverse ) { return short _s . split ( "" ) . reverse ( ) . join ( "" ) ; }
return short _s ;
} ;
return shortString ( url , chunk _l , false ) + "..." + shortString ( url , chunk _l , true ) ;
} ;
/ * *
* Compare 2 arrays / objects
* http : //stackoverflow.com/questions/1773069/using-jquery-to-compare-two-arrays
* /
jQuery . extend ( {
compare : function ( a , b ) {
var obj _str = '[object Object]' ,
arr _str = '[object Array]' ,
a _type = Object . prototype . toString . apply ( a ) ,
b _type = Object . prototype . toString . apply ( b ) ;
if ( a _type !== b _type ) {
return false ;
} else if ( a _type === obj _str ) {
return $ . compareObject ( a , b ) ;
} else if ( a _type === arr _str ) {
return $ . compareArray ( a , b ) ;
}
return ( a === b ) ;
} ,
compareArray : function ( arrayA , arrayB ) {
var a , b , i , a _type , b _type ;
if ( arrayA === arrayB ) { return true ; }
if ( arrayA . length != arrayB . length ) { return false ; }
a = jQuery . extend ( true , [ ] , arrayA ) ;
b = jQuery . extend ( true , [ ] , arrayB ) ;
2018-04-17 21:25:26 +00:00
a . sort ( ) ;
2016-08-18 20:39:31 +00:00
b . sort ( ) ;
for ( i = 0 , l = a . length ; i < l ; i += 1 ) {
a _type = Object . prototype . toString . apply ( a [ i ] ) ;
b _type = Object . prototype . toString . apply ( b [ i ] ) ;
if ( a _type !== b _type ) {
return false ;
}
if ( $ . compare ( a [ i ] , b [ i ] ) === false ) {
return false ;
}
}
return true ;
} ,
compareObject : function ( objA , objB ) {
var i , a _type , b _type ;
2018-04-17 21:25:26 +00:00
// Compare if they are references to each other
2016-08-18 20:39:31 +00:00
if ( objA === objB ) { return true ; }
if ( Object . keys ( objA ) . length !== Object . keys ( objB ) . length ) { return false ; }
for ( i in objA ) {
if ( objA . hasOwnProperty ( i ) ) {
if ( typeof objB [ i ] === 'undefined' ) {
return false ;
} else {
a _type = Object . prototype . toString . apply ( objA [ i ] ) ;
b _type = Object . prototype . toString . apply ( objB [ i ] ) ;
if ( a _type !== b _type ) {
2018-04-17 21:25:26 +00:00
return false ;
2016-08-18 20:39:31 +00:00
}
}
}
if ( $ . compare ( objA [ i ] , objB [ i ] ) === false ) {
return false ;
}
}
return true ;
}
} ) ;
/ * *
* Tells if a selector exits in the dom
* /
jQuery . fn . exists = function ( ) {
return this . length > 0 ;
} ;
/ * *
* Replace . svg for . png
* /
jQuery . fn . replace _svg = function ( ) {
if ( ! this . attr ( "src" ) ) return ;
$ ( this ) . each ( function ( ) {
$ ( this ) . attr ( "src" , $ ( this ) . attr ( "src" ) . replace ( ".svg" , ".png" ) ) ;
} ) ;
} ;
/ * *
* Detect fluid layout
* nota : deberia ir en PF
* /
jQuery . fn . is _fluid = function ( ) {
return true ;
return ( this . hasClass ( "fluid" ) || this . css ( "width" ) == "100%" ) ;
} ;
/ * *
* jQueryfy the form data
* Bind the attributes and values of form data to be manipulated by DOM fn
* /
jQuery . fn . bindFormData = function ( ) {
$ ( ":input" , this ) . each ( function ( ) {
var safeVal = PF . fn . htmlEncode ( $ ( this ) . val ( ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( this ) . is ( "input" ) ) {
this . setAttribute ( "value" , this . value ) ;
if ( this . checked ) {
this . setAttribute ( "checked" , "checked" ) ;
} else {
this . removeAttribute ( "checked" ) ;
}
}
if ( $ ( this ) . is ( "textarea" ) ) {
$ ( this ) . html ( safeVal ) ;
}
if ( $ ( this ) . is ( "select" ) ) {
var index = this . selectedIndex ,
i = 0 ;
$ ( this ) . children ( "option" ) . each ( function ( ) {
if ( i ++ != index ) {
this . removeAttribute ( "selected" ) ;
} else {
this . setAttribute ( "selected" , "selected" ) ;
}
} ) ;
}
} ) ;
return this ;
} ;
2018-04-17 21:25:26 +00:00
/ * * j Q u e r y . f o r m V a l u e s : g e t o r s e t a l l o f t h e n a m e / v a l u e p a i r s f r o m c h i l d i n p u t c o n t r o l s
2016-08-18 20:39:31 +00:00
* @ argument data { array } If included , will populate all child controls .
* @ returns element if data was provided , or array of values if not
* http : //stackoverflow.com/questions/1489486/jquery-plugin-to-serialize-a-form-and-also-restore-populate-the-form
* /
jQuery . fn . formValues = function ( data ) {
var els = $ ( ":input" , this ) ;
if ( typeof data != "object" ) {
data = { } ;
$ . each ( els , function ( ) {
if ( this . name && ! this . disabled && ( this . checked || /select|textarea/i . test ( this . nodeName ) || /color|date|datetime|datetime-local|email|month|range|search|tel|time|url|week|text|number|hidden|password/i . test ( this . type ) ) ) {
if ( this . name . match ( /^.*\[\]$/ ) && this . checked ) {
if ( typeof data [ this . name ] == "undefined" ) {
data [ this . name ] = [ ] ;
}
data [ this . name ] . push ( $ ( this ) . val ( ) ) ;
} else {
data [ this . name ] = $ ( this ) . val ( ) ;
}
}
} ) ;
return data ;
} else {
$ . each ( els , function ( ) {
if ( this . name . match ( /^.*\[\]$/ ) && typeof data [ this . name ] == "object" ) {
$ ( this ) . prop ( "checked" , data [ this . name ] . indexOf ( $ ( this ) . val ( ) ) !== - 1 ) ;
} else {
if ( this . name && data [ this . name ] ) {
if ( /checkbox|radio/i . test ( this . type ) ) {
$ ( this ) . prop ( "checked" , ( data [ this . name ] == $ ( this ) . val ( ) ) ) ;
} else {
$ ( this ) . val ( data [ this . name ] ) ;
}
} else if ( /checkbox|radio/i . test ( this . type ) ) {
$ ( this ) . removeProp ( "checked" ) ;
}
}
} ) ;
return $ ( this ) ;
}
} ;
jQuery . fn . storeformData = function ( dataname ) {
if ( typeof dataname == "undefined" && typeof $ ( this ) . attr ( "id" ) !== "undefined" ) {
2018-04-17 21:25:26 +00:00
dataname = $ ( this ) . attr ( "id" ) ;
2016-08-18 20:39:31 +00:00
}
if ( typeof dataname !== "undefined" ) $ ( this ) . data ( dataname , $ ( this ) . formValues ( ) ) ;
return this ;
} ;
/ * *
* Compare the $ . data values against the current DOM values
* It relies in using $ . data to store the previous value
* Data must be stored using $ . formValues ( )
*
* @ argument dataname string name for the data key
* /
jQuery . fn . is _sameformData = function ( dataname ) {
var $this = $ ( this ) ;
if ( typeof dataname == "undefined" ) dataname = $this . attr ( "id" ) ;
return jQuery . compare ( $this . formValues ( ) , $this . data ( dataname ) ) ;
} ;
/ * *
* Prevent non - numeric keydown
* Allows only numeric keys to be entered on the target event
* /
jQuery . Event . prototype . keydown _numeric = function ( ) {
var e = this ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( e . shiftKey ) {
e . preventDefault ( ) ;
return false ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var key = e . charCode || e . keyCode ,
target = e . target ,
value = ( $ ( target ) . val ( ) == "" ) ? 0 : parseInt ( $ ( target ) . val ( ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( key == 13 ) { // Allow enter key
return true ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( key == 46 || key == 8 || key == 9 || key == 27 ||
// Allow: Ctrl+A
( key == 65 && e . ctrlKey === true ) ||
// Allow: home, end, left, right
( key >= 35 && key <= 40 ) ) {
// let it happen, don't do anything
return true ;
} else {
// Ensure that it is a number and stop the keypress
if ( ( key < 48 || key > 57 ) && ( key < 96 || key > 105 ) ) {
e . preventDefault ( ) ;
}
}
} ;
/ * *
* Detect canvas support
* /
PF . fn . is _canvas _supported = function ( ) {
var elem = document . createElement ( "canvas" ) ;
return ! ! ( elem . getContext && elem . getContext ( "2d" ) ) ;
} ;
/ * *
* Detect validity support
* /
PF . fn . is _validity _supported = function ( ) {
var i = document . createElement ( "input" ) ;
return typeof i . validity === "object" ;
} ;
2018-04-17 21:25:26 +00:00
PF . fn . getScrollBarWidth = function ( ) {
var inner = document . createElement ( 'p' ) ;
inner . style . width = "100%" ;
inner . style . height = "200px" ;
var outer = document . createElement ( 'div' ) ;
outer . style . position = "absolute" ;
outer . style . top = "0px" ;
outer . style . left = "0px" ;
outer . style . visibility = "hidden" ;
outer . style . width = "200px" ;
outer . style . height = "150px" ;
outer . style . overflow = "hidden" ;
outer . appendChild ( inner ) ;
document . body . appendChild ( outer ) ;
var w1 = inner . offsetWidth ;
outer . style . overflow = 'scroll' ;
var w2 = inner . offsetWidth ;
if ( w1 == w2 ) w2 = outer . clientWidth ;
document . body . removeChild ( outer ) ;
return ( w1 - w2 ) ;
2016-08-18 20:39:31 +00:00
} ;
PF . str . ScrollBarWidth = PF . fn . getScrollBarWidth ( ) ;
/ * *
* Updates the notifications button
* /
2018-04-17 21:25:26 +00:00
PF . fn . top _notifications _viewed = function ( ) {
2016-08-18 20:39:31 +00:00
var $top _bar _notifications = $ ( "[data-action=top-bar-notifications]" ) ,
$notifications _lists = $ ( ".top-bar-notifications-list" , $top _bar _notifications ) ,
$notifications _count = $ ( ".top-btn-number" , $top _bar _notifications ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( ".persistent" , $top _bar _notifications ) . exists ( ) ) {
$notifications _count . text ( $ ( ".persistent" , $top _bar _notifications ) . length ) . addClass ( "on" ) ;
} else {
$notifications _count . removeClass ( "on" ) ;
}
} ;
/ * *
* bind tipTip for the $target with options
* @ argument $target selector or jQuery obj
* @ argument options obj
* /
PF . fn . bindtipTip = function ( $target , options ) {
if ( typeof $target == "undefined" ) $target = $ ( "body" ) ;
if ( $target instanceof jQuery == false ) $target = $ ( $target ) ;
var bindtipTipoptions = {
delay : 0 ,
content : false ,
fadeIn : 0
} ;
if ( typeof options !== "undefined" ) {
if ( typeof options . delay !== "undefined" ) bindtipTipoptions . delay = options . delay ;
if ( typeof options . content !== "undefined" ) bindtipTipoptions . content = options . content ;
if ( typeof options . content !== "undefined" ) bindtipTipoptions . fadeIn = options . fadeIn ;
}
if ( $target . attr ( "rel" ) !== "tooltip" ) $target = $ ( "[rel=tooltip]" , $target ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$target . each ( function ( ) {
if ( ( typeof $ ( this ) . attr ( "href" ) !== "undefined" || typeof $ ( this ) . data ( "href" ) !== "undefined" ) && PF . fn . isDevice ( [ "phone" , "phablet" , "tablet" ] ) ) {
return true ;
}
var position = typeof $ ( this ) . data ( "tiptip" ) == "undefined" ? "bottom" : $ ( this ) . data ( "tiptip" ) ;
if ( PF . fn . isDevice ( [ "phone" , "phablet" ] ) ) {
position = "top" ;
}
$ ( this ) . tipTip ( { delay : bindtipTipoptions . delay , defaultPosition : position , content : bindtipTipoptions . content , fadeIn : bindtipTipoptions . fadeIn , fadeOut : 0 } ) ;
} ) ;
} ;
/ * *
* form modal changed
* Detects if the form modal ( fullscreen ) has changed or not
2018-04-17 21:25:26 +00:00
* Note : It relies in that you save a serialized data to the
2016-08-18 20:39:31 +00:00
* /
PF . fn . form _modal _has _changed = function ( ) {
if ( $ ( PF . obj . modal . selectors . root ) . is ( ":hidden" ) ) return ;
if ( typeof $ ( "html" ) . data ( "modal-form-values" ) == typeof undefined ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var data _stored = $ ( "html" ) . data ( "modal-form-values" ) ;
var data _modal = PF . fn . deparam ( $ ( ":input:visible" , PF . obj . modal . selectors . root ) . serialize ( ) ) ;
var has _changed = false ;
var keys = $ . extend ( { } , data _stored , data _modal ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( var k in keys ) {
if ( data _stored [ k ] !== data _modal [ k ] ) {
has _changed = true ;
break ;
}
}
return has _changed ;
} ;
/ * *
* PEAFOWL CONDITIONALS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . fn . is _listing = function ( ) {
return $ ( PF . obj . listing . selectors . content _listing ) . exists ( ) ;
} ;
PF . fn . is _tabs = function ( ) {
return $ ( ".content-tabs" ) . exists ( ) ;
} ;
/ * *
* PEAFOWL EFFECTS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
/ * *
* Shake effect
* Shakes the element using CSS animations .
* @ argument callback fn
* /
jQuery . fn . shake = function ( callback ) {
this . each ( function ( init ) {
var jqNode = $ ( this ) ,
jqNode _position = jqNode . css ( "position" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! jqNode _position . match ( "relative|absolute|fixed" ) ) jqNode . css ( { position : "relative" } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var jqNode _left = parseInt ( jqNode . css ( "left" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! jqNode _left . toString ( ) . isNumeric ( ) ) jqNode _left = 0 ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! jqNode . is ( ":animated" ) ) {
for ( var x = 1 ; x <= 2 ; x ++ ) {
jqNode . animate ( {
left : jqNode _left - 10
} , 0 ) . animate ( {
left : jqNode _left
} , 30 ) . animate ( {
left : jqNode _left + 10
} , 30 ) . animate ( {
left : jqNode _left
} , 30 ) ;
} ;
if ( jqNode _position !== "static" ) jqNode . css ( { position : jqNode _position } ) ;
} ;
} ) ;
if ( typeof callback == "function" ) callback ( ) ;
return this ;
} ;
/ * *
* Highlight effect
* Changes the background of the element to a highlight color and revert to original
* @ argument string ( yellow | red | hex - color )
* /
jQuery . fn . highlight = function ( color ) {
if ( this . is ( ":animated" ) || ! this . exists ( ) ) return this ;
if ( typeof color == "undefined" ) color = "yellow" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var fadecolor = color ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
switch ( color ) {
case "yellow" :
fadecolor = "#FFFBA2" ;
break ;
case "red" :
fadecolor = "#FF7F7F" ;
break ;
default :
fadecolor = color ;
break ;
} ;
var base _background _color = $ ( this ) . css ( "background-color" ) ,
base _background = $ ( this ) . css ( "background" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . css ( { background : "" , backgroundColor : fadecolor } ) . animate ( { backgroundColor : base _background _color } , 800 , function ( ) {
$ ( this ) . css ( "background" , "" ) ;
} ) ;
return this ;
} ;
/ * *
* Peafowl slidedown effect
* Bring the element using slideDown - type effect
* @ argument speed ( fast | normal | slow | int )
* @ argument callback fn
* /
jQuery . fn . pf _slideDown = function ( speed , callback ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var default _speed = "normal" ,
this _length = $ ( this ) . length ,
css _prechanges , css _animation , animation _speed ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof speed == "function" ) {
callback = speed ;
2018-04-17 21:25:26 +00:00
speed = default _speed ;
2016-08-18 20:39:31 +00:00
}
if ( typeof speed == "undefined" ) {
speed = default _speed ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . each ( function ( index ) {
var this _css _top = parseInt ( $ ( this ) . css ( "top" ) ) ,
to _top = this _css _top > 0 ? this _css _top : 0 ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( speed == 0 ) {
css _prechanges = { display : "block" , opacity : 0 } ,
css _animation = { opacity : 1 } ,
animation _speed = jQuery . speed ( "fast" ) . duration ;
} else {
css _prechanges = { top : - $ ( this ) . outerHeight ( true ) , opacity : 1 , display : "block" } ;
css _animation = { top : to _top } ;
animation _speed = jQuery . speed ( speed ) . duration ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . data ( "originalTop" , $ ( this ) . css ( "top" ) ) ;
$ ( this ) . css ( css _prechanges ) . animate ( css _animation , animation _speed , function ( ) {
if ( index == this _length - 1 ) {
if ( typeof callback == "function" ) {
callback ( ) ;
}
}
} ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
return this ;
} ;
/ * *
* Peafowl slideUp effect
* Move the element using slideUp - type effect
* @ argument speed ( fast | normal | slow | int )
* @ argument callback fn
2018-04-17 21:25:26 +00:00
* /
2016-08-18 20:39:31 +00:00
jQuery . fn . pf _slideUp = function ( speed , callback ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var default _speed = "normal" ,
this _length = $ ( this ) . length ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof speed == "function" ) {
callback = speed ;
2018-04-17 21:25:26 +00:00
speed = default _speed ;
2016-08-18 20:39:31 +00:00
}
if ( typeof speed == "undefined" ) {
speed = default _speed ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . each ( function ( index ) {
$ ( this ) . animate ( { top : - $ ( this ) . outerHeight ( true ) } , jQuery . speed ( speed ) . duration , function ( ) {
$ ( this ) . css ( { display : "none" , top : $ ( this ) . data ( "originalTop" ) } ) ;
if ( index == this _length - 1 ) {
if ( typeof callback == "function" ) {
callback ( ) ;
}
}
} ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
return this ;
} ;
/ * *
* Peafowl visible on viewport
* /
jQuery . fn . is _in _viewport = function ( ) {
var rect = $ ( this ) [ 0 ] . getBoundingClientRect ( ) ;
return (
rect . top >= 0 &&
rect . left >= 0 &&
rect . bottom <= ( window . innerHeight || document . documentElement . clientHeight ) && /*or $(window).height() */
rect . right <= ( window . innerWidth || document . documentElement . clientWidth ) /*or $(window).width() */
) ;
} ;
2018-04-17 21:25:26 +00:00
/ * *
* Visible on current window stuff
* /
jQuery . fn . getWindowCutoff = function ( ) {
var rect = {
top : $ ( this ) . offset ( ) . top ,
left : $ ( this ) . offset ( ) . left ,
width : $ ( this ) . outerWidth ( ) ,
height : $ ( this ) . outerHeight ( ) ,
} ;
rect . right = rect . left + rect . width ;
rect . bottom = rect . top + rect . height ;
var detected = false ;
var cutoff = {
top : rect . top > 0 ? 0 : rect . top ,
right : document . body . clientWidth - rect . right ,
bottom : document . body . clientHeight - rect . bottom ,
left : rect . left > 0 ? 0 : rect . left ,
} ;
for ( var key in cutoff ) {
if ( cutoff [ key ] < 0 ) {
detected = true ;
} else {
cutoff [ key ] = 0 ;
}
}
if ( ! detected ) return null ;
return cutoff ;
} ;
2016-08-18 20:39:31 +00:00
/ * *
* Scroll the window to the target .
* @ argument target selector
* @ argument callback fn
* /
PF . fn . scroll = function ( target , callback ) {
if ( typeof target == "function" ) {
var callback = target ,
target = "" ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var pxtop = parseInt ( $ ( "body" ) . css ( "margin-top" ) ) ;
if ( pxtop == 0 && $ ( ".top-bar-placeholder" ) . exists ( ) ) {
pxtop = $ ( ".top-bar-placeholder" ) . height ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $ ( target ) . exists ( ) ) target = "html" ;
$ ( "body,html" ) . animate ( { scrollTop : $ ( target ) . offset ( ) . top - pxtop } , "normal" , function ( ) {
if ( typeof callback == "function" ) callback ( ) ;
} ) ;
} ;
PF . fn . close _pops = function ( e ) {
$ ( ".pop-box:visible" ) . each ( function ( ) {
$ ( this ) . closest ( ".pop-btn" ) . click ( ) ;
} ) ;
} ;
/ * *
* Bring up a nice growl - like alert
* /
PF . fn . growl = {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
selectors : {
root : "#growl"
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
str : {
timeout : null ,
timeoutcall : false
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Fires the growl
* @ argument options object
* /
call : function ( options ) {
if ( typeof options == "undefined" ) return ;
if ( typeof options == "string" ) {
options = { message : options } ;
}
if ( typeof options . message == "undefined" ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var growl _options , $growl , growl _class , growl _color ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
growl _options = {
message : options . message ,
insertTo : "body" ,
where : "before" ,
color : "default" ,
css : { } ,
classes : "" ,
expires : 0 ,
callback : function ( ) { }
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( key in growl _options ) {
if ( typeof options [ key ] !== "undefined" ) {
if ( key . match ( "/^(callback)$/" ) ) {
if ( typeof options [ key ] == "function" ) {
growl _options [ key ] = options [ key ] ;
}
} else {
growl _options [ key ] = options [ key ] ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
}
if ( ! $ ( growl _options . insertTo ) . exists ( ) ) {
growl _options . insertTo = "body" ;
}
if ( $ ( PF . fn . growl . selectors . root ) . exists ( ) ) {
if ( $ ( PF . fn . growl . selectors . root ) . text ( ) == growl _options . message ) {
$ ( PF . fn . growl . selectors . root ) . shake ( ) ;
return ;
}
$ ( PF . fn . growl . selectors . root ) . remove ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$growl = $ ( '<div id="' + PF . fn . growl . selectors . root . replace ( "#" , "" ) + '" class="growl">' + growl _options . message + '<span class="icon icon-close" data-action="close"></span></div>' ) . css ( growl _options . css ) . addClass ( growl _options . classes ) ;
growl _class = growl _options . insertTo !== "body" ? "static" : "" ;
switch ( growl _options . color ) {
case "dark" :
growl _color = "dark" ;
break ;
default :
growl _color = "" ;
break ;
}
$growl . addClass ( growl _class + " " + growl _color ) ;
if ( growl _options . where == "before" ) {
$ ( growl _options . insertTo ) . prepend ( $growl . hide ( ) ) ;
} else {
$ ( growl _options . insertTo ) . append ( $growl . hide ( ) ) ;
}
if ( $ ( ".fullscreen" ) . is ( ":visible" ) ) {
$growl . css ( { "z-index" : parseInt ( $ ( ".fullscreen" ) . css ( "z-index" ) ) + 1 } ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( PF . obj . modal . selectors . root ) . is ( ":visible" ) ) {
var $modal _box = $ ( PF . obj . modal . selectors . box , PF . obj . modal . selectors . root ) ;
$growl . show ( ) ;
$growl . css ( "top" , ( $ ( "#top-bar" ) . outerHeight ( true ) - $growl . outerHeight ( true ) ) / 2 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . growl . fixPosition ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$growl . hide ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$growl . pf _slideDown ( growl _class == "static" ? 0 : 200 , function ( ) {
if ( typeof growl _options . callback == "function" ) {
growl _options . callback ( ) ;
}
} ) ;
$ ( document ) . on ( "click" , ".growl" , function ( e ) {
if ( PF . fn . isDevice ( [ "phone" , "phablet" ] ) || $ ( e . target ) . is ( "[data-action=close]" ) ) {
PF . fn . growl . close ( true ) ;
}
} ) ;
if ( growl _options . expires > 0 ) {
if ( typeof this . str . timeout == "number" ) {
clearTimeout ( this . str . timeout ) ;
}
this . str . timeout = setTimeout ( function ( ) {
PF . fn . growl . str . timeoutcall = true ;
PF . fn . growl . close ( ) ;
} , growl _options . expires ) ;
}
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Fires an expirable growl ( will close after time )
* @ argument msg string
* @ argument time int ( ms )
* /
expirable : function ( msg , time ) {
if ( typeof msg == "undefined" ) return ;
if ( typeof time == "undefined" ) time = 5000 ;
PF . fn . growl . call ( { message : msg , expires : time } ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Closes the growl
* @ argument callback fn
* /
close : function ( forced , callback ) {
var $growl = $ ( PF . fn . growl . selectors . root ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( forced ) {
this . str . timeout = null ;
this . str . timeoutcall = false ;
clearTimeout ( this . str . timeout ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $growl . exists ( ) || ( typeof this . str . timeout == "number" && ! this . str . timeoutcall ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$growl . fadeOut ( "fast" , function ( ) {
$ ( this ) . remove ( ) ;
if ( typeof callback == "function" ) {
callback ( ) ;
}
} ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
fixPosition : function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $growl = $ ( PF . fn . growl . selectors . root ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $growl . exists ( ) || ! $ ( PF . obj . modal . selectors . root ) . exists ( ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $growl . data ( "fixedPosition" ) == "scrollbar" && $ ( PF . obj . modal . selectors . root ) . hasScrollBar ( ) . vertical ) {
return ;
}
var offsetX = {
modal : $ ( PF . obj . modal . selectors . box ) . offset ( ) . left ,
growl : $growl . offset ( ) . left
} ,
growlCompensate = offsetX . modal - offsetX . growl ,
marginLeft = growlCompensate < 0 ? ( "-=" + Math . abs ( growlCompensate ) ) : "-" + parseInt ( $growl . css ( "width" ) ) / 2 ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! PF . fn . isDevice ( [ "phone" , "phablet" ] ) ) {
$growl . css ( "marginLeft" , marginLeft + "px" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$growl . data ( "fixedPosition" , $ ( PF . obj . modal . selectors . root ) . hasScrollBar ( ) . vertical ? "scrollbar" : "no-scrollbar" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ;
/ * *
* Bring up a nice fullscreen modal
* /
PF . obj . modal = {
type : "" ,
selectors : {
root : "#fullscreen-modal" ,
box : "#fullscreen-modal-box" ,
body : "#fullscreen-modal-body" ,
login : "[data-modal=login]" ,
changes _confirm : "#fullscreen-changes-confirm" ,
btn _container : ".btn-container" ,
close _buttons : ".close-modal,.cancel-modal,[data-action=cancel],[data-action-close]" ,
submit _button : "[data-action=submit]" ,
growl _placeholder : "#fullscreen-growl-placeholder"
} ,
ajax : {
url : "" ,
deferred : { }
} ,
locked : false ,
form _data : { } ,
XHR : { } ,
prevented : false
} ;
PF . obj . modal . $close _buttons = $ ( PF . obj . modal . selectors . close _buttons , PF . obj . modal . selectors . root ) ;
PF . obj . modal . $submit _button = $ ( PF . obj . modal . selectors . submit _button , PF . obj . modal . selectors . root ) ;
PF . fn . modal = {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
str : {
transition : "all " + PF . obj . config . animation . fast + "ms ease"
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Fires the modal
* @ argument options object
* /
call :
function ( options ) {
var modal _options , modal _base _template , modal _message ;
2017-11-09 19:02:18 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof options == "undefined" ) return ;
2018-04-17 21:25:26 +00:00
if ( typeof options . template !== "undefined" && typeof options . type == "undefined" ) options . type = "html" ;
2016-08-18 20:39:31 +00:00
if ( ( typeof options . title == "undefined" || typeof options . message == "undefined" ) && ( options . type !== "login" && options . type !== "html" ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . growl . close ( ) ;
modal _options = {
forced : false ,
type : "confirm" ,
title : options . title ,
message : options . message ,
html : false ,
template : options . template ,
buttons : true ,
button _submit : PF . fn . _s ( "Submit" ) ,
txt _or : PF . fn . _s ( "or" ) ,
button _cancel : PF . fn . _s ( "cancel" ) ,
ajax : { url : null , data : null , deferred : { } } ,
2017-11-09 19:02:18 +00:00
confirm : function ( ) { } ,
2016-08-18 20:39:31 +00:00
cancel : function ( ) {
PF . fn . modal . close ( ) ;
} ,
2017-05-21 20:19:25 +00:00
load : function ( ) { } ,
2016-08-18 20:39:31 +00:00
callback : function ( ) { }
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( key in modal _options ) {
if ( typeof options [ key ] !== "undefined" ) {
if ( ( /^cancel|confirm|callback$/ ) . test ( key ) ) {
if ( typeof options [ key ] == "function" ) {
modal _options [ key ] = options [ key ] ;
}
} else {
modal _options [ key ] = options [ key ] ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof options . ajax !== "undefined" && ! options . ajax . url && options . ajax . deferred ) {
modal _options . ajax . url = PF . obj . config . json _api ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _options . type == "login" ) {
modal _options . buttons = false ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _options . type == "confirm" ) {
modal _options . button _submit = PF . fn . _s ( "Confirm" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var overlay _background = "soft-black" ;
if ( $ ( "html" ) . hasClass ( "tone-dark" ) ) {
overlay _background = "black" ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var modal _base _template = [
'<div id="' , PF . obj . modal . selectors . root . replace ( "#" , "" ) ,
'"class="fullscreen ' + overlay _background + '"><div id="' ,
PF . obj . modal . selectors . box . replace ( "#" , "" ) ,
'"class="clickable"><div id="' , PF . obj . modal . selectors . body . replace ( "#" , "" ) ,
'">%MODAL_BODY%</div>%MODAL_BUTTONS%<span class="close-modal icon-close" data-action="close-modal"></span></div></div>'
] . join ( "" ) ;
var modal _buttons = modal _options . buttons ? [ '<div class="' , PF . obj . modal . selectors . btn _container . replace ( "." , "" ) , '"><button class="btn btn-input default" data-action="submit" type="submit">' , modal _options . button _submit , '</button> <span class="btn-alt">' , modal _options . txt _or , '<a class="cancel" data-action="cancel">' , modal _options . button _cancel , '</a></span></div>' ] . join ( "" ) : "" ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _options . type == "login" ) {
modal _options . template = typeof modal _options . template == "undefined" ? $ ( PF . obj . modal . selectors . login ) . html ( ) : modal _options . template ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var modalBodyHTML ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
switch ( modal _options . type ) {
case "html" :
case "login" :
modalBodyHTML = modal _options . template ;
break ;
case "confirm" : default :
modal _message = modal _options . message ;
if ( ! modal _options . html ) {
modal _message = '<p>' + modal _message + '</p>' ;
}
modalBodyHTML = '<h1>' + modal _options . title + '</h1>' + modal _message ;
break ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof modalBodyHTML == "undefined" ) {
console . log ( "PF Error: Modal content is empty" ) ;
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
modal _base _template = modal _base _template
. replace ( "%MODAL_BODY%" , modalBodyHTML )
. replace ( "%MODAL_BUTTONS%" , modal _buttons )
. replace ( /template-tooltip/g , "tooltip" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . modal . selectors . root ) . remove ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "body" ) . data ( "overflow-hidden" , $ ( "body" ) . hasClass ( "overflow-hidden" ) ) ;
$ ( "body" ) . prepend ( modal _base _template ) . addClass ( "overflow-hidden" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
this . fixScrollbars ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "[rel=tooltip]" , PF . obj . modal . selectors . root ) . each ( function ( ) {
PF . fn . bindtipTip ( this , { content : $ ( this ) . data ( "title" ) } ) ;
} ) ;
if ( $ ( ":button, input[type=submit], input[type=reset]" , PF . obj . modal . selectors . root ) . length > 0 ) {
var $form = $ ( "form" , PF . obj . modal . selectors . root ) ;
if ( $form . exists ( ) ) {
$form . append ( $ ( $ ( PF . obj . modal . selectors . btn _container , PF . obj . modal . selectors . root ) . html ( ) ) . wrapInner ( PF . obj . modal . selectors . btn _container . replace ( "." , "" ) ) ) ;
$ ( PF . obj . modal . selectors . btn _container , PF . obj . modal . selectors . root ) . each ( function ( ) {
if ( ! $ ( this ) . closest ( "form" ) . exists ( ) ) {
$ ( this ) . remove ( ) ;
}
} ) ;
} else {
$ ( PF . obj . modal . selectors . box , PF . obj . modal . selectors . root ) . wrapInner ( '<form />' ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
modal _options . callback ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . modal . selectors . box ) . css ( { transform : "scale(0.7)" , opacity : 0 , transition : PF . fn . modal . str . transition } ) ;
$ ( PF . obj . modal . selectors . root ) . css ( { display : "block" } ) ;
setTimeout ( function ( ) {
$ ( PF . obj . modal . selectors . root ) . css ( { opacity : 1 } ) ;
$ ( PF . obj . modal . selectors . box ) . css ( { transform : "scale(1)" , opacity : 1 } ) ;
2017-11-09 19:02:18 +00:00
if ( typeof PFrecaptchaCallback !== typeof undefined ) {
PFrecaptchaCallback ( ) ;
}
2016-08-18 20:39:31 +00:00
setTimeout ( function ( ) {
if ( typeof modal _options . load == "function" ) {
modal _options . load ( ) ;
}
2017-11-09 19:02:18 +00:00
// Stock default modal values
2016-08-18 20:39:31 +00:00
$ ( "html" ) . data ( "modal-form-values" , PF . fn . deparam ( $ ( ":input:visible" , PF . obj . modal . selectors . root ) . serialize ( ) ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} , PF . obj . config . animation . fast ) ;
} , 1 ) ;
// Bind the modal events
$ ( PF . obj . modal . selectors . root ) . click ( function ( e ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $this = $ ( e . target ) ,
_this = this ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . obj . modal . locked ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Changes confirm?
if ( $this . closest ( PF . obj . modal . selectors . changes _confirm ) . exists ( ) && ( $this . is ( PF . obj . modal . selectors . close _buttons ) || $this . is ( PF . obj . modal . selectors . submit _button ) ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . modal . selectors . changes _confirm ) . remove ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $this . is ( PF . obj . modal . selectors . close _buttons ) ) {
$ ( PF . obj . modal . selectors . box , _this ) . fadeIn ( "fast" , function ( ) {
$ ( this ) . css ( "transition" , PF . fn . modal . str . transition ) ;
} ) ;
} else {
PF . fn . modal . close ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Modal
} else {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $this . closest ( ".clickable" ) . exists ( ) || $this . is ( PF . obj . modal . selectors . close _buttons ) ) {
PF . fn . growl . close ( ) ;
modal _options . cancel ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $this . is ( PF . obj . modal . selectors . submit _button ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _options . confirm ( ) === false ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var modal _submit _continue = true ;
if ( $ ( "input, textarea, select" , PF . obj . modal . selectors . root ) . not ( ":input[type=button], :input[type=submit], :input[type=reset]" ) . length > 0 && ! PF . fn . form _modal _has _changed ( ) && ! modal _options . forced ) {
modal _submit _continue = false ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _submit _continue ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( modal _options . ajax . url ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $btn _container = $ ( PF . obj . modal . selectors . btn _container , PF . obj . modal . selectors . root ) ;
PF . obj . modal . locked = true ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$btn _container . first ( ) . clone ( ) . height ( $btn _container . height ( ) ) . html ( "" ) . addClass ( "loading" ) . appendTo ( PF . obj . modal . selectors . root + " form" ) ;
$btn _container . hide ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . modal . $close _buttons . hide ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var modal _loading _msg ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
switch ( PF . obj . modal . type ) {
case "edit" :
modal _loading _msg = PF . fn . _s ( "Saving" ) ;
break ;
case "confirm" :
case "form" :
default :
modal _loading _msg = PF . fn . _s ( "Sending" ) ;
break ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . loading . inline ( $ ( PF . obj . modal . selectors . btn _container + ".loading" , PF . obj . modal . selectors . root ) , { size : "small" , message : modal _loading _msg , valign : "center" } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . modal . selectors . root ) . disableForm ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $ . isEmptyObject ( PF . obj . modal . form _data ) || ( typeof options . ajax !== "undefined" && typeof options . ajax . data == "undefined" ) ) {
modal _options . ajax . data = PF . obj . modal . form _data ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . modal . XHR = $ . ajax ( {
url : modal _options . ajax . url ,
type : "POST" ,
data : modal _options . ajax . data //PF.obj.modal.form_data // $.param ?
} ) . complete ( function ( XHR ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . modal . locked = false ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( XHR . status == 200 ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var success _fn = typeof modal _options . ajax . deferred !== "undefined" && typeof modal _options . ajax . deferred . success !== "undefined" ? modal _options . ajax . deferred . success : null ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof success _fn == "function" ) {
PF . fn . modal . close ( function ( ) {
if ( typeof success _fn == "function" ) {
success _fn ( XHR ) ;
}
} ) ;
} else if ( typeof success _fn == "object" ) {
if ( typeof success _fn . before == "function" ) {
success _fn . before ( XHR ) ;
}
if ( typeof success _fn . done == "function" ) {
success _fn . done ( XHR ) ;
}
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
} else {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . modal . selectors . root ) . enableForm ( ) ;
$ ( PF . obj . modal . selectors . btn _container + ".loading" , PF . obj . modal . selectors . root ) . remove ( ) ;
$btn _container . css ( "display" , "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof modal _options . ajax . deferred !== "undefined" && typeof modal _options . ajax . deferred . error == "function" ) {
modal _options . ajax . deferred . error ( XHR ) ;
} else {
var message = PF . fn . _s ( "An error occurred. Please try again later." ) ;
/ *
if ( XHR . responseJSON . error . message ) {
message = XHR . responseJSON . error . message ;
}
* /
PF . fn . growl . call ( message ) ;
}
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} else {
// No ajax behaviour
PF . fn . modal . close ( modal _options . callback ( ) ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
}
}
} ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Fires a confirm modal
* @ argument options object
* /
confirm :
function ( options ) {
options . type = "confirm" ;
if ( typeof options . title == "undefined" ) {
options . title = PF . fn . _s ( "Confirm action" ) ;
}
PF . fn . modal . call ( options ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Fires a simple info modal
* /
simple :
function ( options ) {
if ( typeof options == "string" ) options = { message : options } ;
if ( typeof options . buttons == "undefined" ) options . buttons = false ;
if ( typeof options . title == "undefined" ) options . title = PF . fn . _s ( "information" ) ;
PF . fn . modal . call ( options ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
fixScrollbars :
function ( ) {
if ( ! $ ( PF . obj . modal . selectors . root ) . exists ( ) ) {
return ;
}
var $targets = {
padding : $ ( ".top-bar, .fixed, .position-fixed" ) ,
margin : $ ( "html" ) ,
}
var properties = { }
if ( PF . str . ScrollBarWidth > 0 && $ ( "html" ) . hasScrollBar ( ) . vertical && ! $ ( "body" ) . data ( "overflow-hidden" ) ) {
properties . padding = PF . str . ScrollBarWidth + "px" ;
properties . margin = PF . str . ScrollBarWidth + "px" ;
} else {
properties . padding = "" ;
properties . margin = "" ;
}
$targets . padding . css ( { paddingRight : properties . padding } ) ;
$targets . margin . css ( { marginRight : properties . margin } ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* Closes the modal
* @ argument callback fn
* /
close :
function ( callback ) {
if ( ! $ ( PF . obj . modal . selectors . root ) . exists ( ) ) {
return ;
}
PF . fn . growl . close ( true ) ;
$ ( "[rel=tooltip]" , PF . obj . modal . selectors . root ) . tipTip ( "hide" ) ;
$ ( PF . obj . modal . selectors . box ) . css ( { transform : "scale(0.5)" , opacity : 0 } ) ;
$ ( PF . obj . modal . selectors . root ) . css ( { opacity : 0 } ) ;
setTimeout ( function ( ) {
if ( PF . str . ScrollBarWidth > 0 && $ ( "html" ) . hasScrollBar ( ) . vertical ) {
$ ( ".top-bar, .fixed, .position-fixed" ) . css ( { paddingRight : "" } ) ;
}
$ ( "html" ) . css ( { marginRight : "" } ) ;
if ( ! $ ( "body" ) . data ( "overflow-hidden" ) ) {
$ ( "body" ) . removeClass ( "overflow-hidden" ) ;
}
$ ( "body" ) . removeData ( "overflow-hidden" ) ;
$ ( PF . obj . modal . selectors . root ) . remove ( ) ;
if ( typeof callback == "function" ) callback ( ) ;
} , PF . obj . config . animation . normal ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ;
/ * *
* Peafowlesque popups
* /
PF . fn . popup = function ( options ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var settings = {
height : options . height || 500 ,
width : options . width || 650 ,
scrollTo : 0 ,
resizable : 0 ,
scrollbars : 0 ,
location : 0
} ;
settings . top = ( screen . height / 2 ) - ( settings . height / 2 ) ;
settings . left = ( screen . width / 2 ) - ( settings . width / 2 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var settings _ = "" ;
for ( var key in settings ) {
settings _ += key + "=" + settings [ key ] + "," ;
}
settings _ = settings _ . slice ( 0 , - 1 ) ; // remove the last comma
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
window . open ( options . href , "Popup" , settings _ ) ;
return ;
} ;
/ * *
* PEAFOWL FLUID WIDTH FIXER
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . fn . list _fluid _width = function ( ) {
if ( ! $ ( "body" ) . is _fluid ( ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $content _listing = $ ( PF . obj . listing . selectors . content _listing _visible ) ,
$pad _content _listing = $ ( PF . obj . listing . selectors . pad _content , $content _listing ) ,
$list _item = $ ( PF . obj . listing . selectors . list _item , $content _listing ) ,
list _item _width = $list _item . outerWidth ( true ) ,
list _item _gutter = $list _item . outerWidth ( true ) - $list _item . width ( ) ;
PF . obj . listing . content _listing _ratio = parseInt ( ( $content _listing . width ( ) + list _item _gutter ) / list _item _width ) ;
if ( $list _item . length < PF . obj . listing . content _listing _ratio ) {
$pad _content _listing . css ( "width" , "100%" ) ;
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . fn . isDevice ( [ "tablet" , "laptop" , "desktop" ] ) ) {
// $pad_content_listing.width((PF.obj.listing.content_listing_ratio * list_item_width) - list_item_gutter);
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . obj . follow _scroll . $node . hasClass ( "position-fixed" ) ) {
PF . obj . follow _scroll . $node . width ( $ ( ".content-width" ) . first ( ) . width ( ) ) ;
}
} ;
/ * *
* PEAFOWL TABS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . obj . tabs = {
hashdata : { }
} ;
PF . fn . show _tab = function ( tab ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof tab == "undefined" ) return ;
var $this = $ ( "a[data-tab=" + tab + "]" , ".content-tabs" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "li" , $this . closest ( "ul" ) ) . removeClass ( "current" ) ;
$this . closest ( "li" ) . addClass ( "current" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $tab _content _group = $ ( "#tabbed-content-group" ) ;
$target = $ ( "#" + $this . data ( "tab" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".tabbed-content" , $tab _content _group ) . removeClass ( "visible" ) . hide ( ) ;
$ ( $target , $tab _content _group ) . addClass ( "visible" ) . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Show/hide the listing sorting
$ ( "[data-content=list-selection]" ) . removeClass ( "visible" ) . addClass ( "hidden" ) ;
$ ( "[data-content=list-selection][data-tab=" + $this . data ( "tab" ) + "]" ) . removeClass ( "hidden" ) . addClass ( "visible" ) ;
if ( $tab _content _group . exists ( ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $list _item _target = $ ( PF . obj . listing . selectors . list _item + ":not(.jsly)" , $target ) ,
target _fade = ! $target . hasClass ( "jsly" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target . data ( "load" ) == "ajax" && $target . data ( "empty" ) !== "true" && ! $ ( PF . obj . listing . selectors . list _item , $target ) . exists ( ) ) {
PF . fn . listing . queryString . stock _load ( ) ;
$target . html ( PF . obj . listing . template . fill ) ;
PF . fn . loading . inline ( $ ( PF . obj . listing . selectors . content _listing _loading , $target ) ) ;
PF . fn . listing . queryString . stock _new ( ) ;
PF . fn . listing . ajax ( ) ;
} else {
PF . fn . listing . queryString . stock _current ( ) ;
PF . fn . listing . columnizer ( false , 0 , false ) ;
$list _item _target [ target _fade ? "fadeIn" : "show" ] ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . listing . columnizerQueue ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( PF . obj . listing . selectors . content _listing _visible ) . data ( "queued" ) == true ) {
PF . fn . listing . columnizer ( true , 0 ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ;
/ * *
* PEAFOWL LISTINGS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . obj . listing = {
columns : "" ,
columns _number : 1 ,
current _column : "" ,
current _column : "" ,
XHR : { } ,
query _string : PF . fn . get _url _vars ( ) ,
calling : false ,
content _listing _ratio : 1 ,
selectors : {
sort : ".sort-listing .current [data-sort]" ,
content _listing : ".content-listing" ,
content _listing _visible : ".content-listing:visible" ,
content _listing _loading : ".content-listing-loading" ,
content _listing _load _more : ".content-listing-more" ,
content _listing _pagination : ".content-listing-pagination" ,
empty _icon : ".icon icon-drawer" ,
pad _content : ".pad-content-listing" ,
list _item : ".list-item" ,
} ,
template : {
fill : $ ( "[data-template=content-listing]" ) . html ( ) ,
empty : $ ( "[data-template=content-listing-empty]" ) . html ( ) ,
loading : $ ( "[data-template=content-listing-loading]" ) . html ( )
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
} ;
PF . fn . listing = { } ;
PF . fn . listing . show = function ( response , callback ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$content _listing = $ ( "#content-listing-tabs" ) . exists ( ) ? $ ( PF . obj . listing . selectors . content _listing _visible , "#content-listing-tabs" ) : $ ( PF . obj . listing . selectors . content _listing ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . loading . inline ( PF . obj . listing . selectors . content _listing _loading ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . listing . selectors . list _item + ":not(.jsly)" , $content _listing ) . each ( function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . imagesLoaded ( function ( i ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var items = PF . obj . listing . selectors . list _item ,
$subjects = $ ( items + ":visible" , PF . obj . listing . selectors . content _listing _visible ) ,
$targets = $ ( i . elements ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ( typeof response !== "undefined" && $ ( response . html ) . length < PF . obj . config . listing . items _per _page ) || $ ( PF . obj . listing . selectors . list _item , $content _listing ) . length < PF . obj . config . listing . items _per _page ) {
PF . fn . listing . removeLoader ( $content _listing ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( PF . obj . listing . selectors . content _listing _pagination , $content _listing ) . is ( "[data-type=classic]" ) || ! $ ( "[data-action=load-more]" , $content _listing ) . exists ( ) ) {
$ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) . remove ( ) ;
}
if ( $subjects . length == 0 ) {
$targets . show ( ) ;
PF . fn . listing . columnizer ( false , 0 ) ;
PF . obj . listing . recolumnize = true ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
//var animation_time = $subjects.length == 0 ? 0 : null;
var animation _time = 0 ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . listing . columnizer ( PF . obj . listing . recolumnize , animation _time , $subjects . length == 0 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$targets . hide ( ) ;
PF . obj . listing . recolumnize = false ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . fn . isDevice ( [ "laptop" , "desktop" ] ) ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$targets . each ( function ( ) { // too much CPU for this
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . show ( ) . find ( ".image-container" ) . hide ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var callTime = $ . now ( ) ;
var $this = $ ( this ) ;
var $target = $ ( ".image-container" , $this ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".image-container" , this ) . imagesLoaded ( function ( ) {
var loadTime = $ . now ( ) - callTime ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $subjects . length == 0 ) {
if ( loadTime > PF . obj . config . animation . normal ) {
$target . fadeIn ( PF . obj . config . animation . normal ) ;
} else {
$target . show ( ) ;
}
} else {
$target . fadeIn ( PF . obj . config . animation . normal ) ;
}
} ) ;
} ) ;
} else {
$targets . show ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . calling = false ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var visible _loading = $ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) . exists ( ) && ( $ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) . is _in _viewport ( ) ) ;
if ( typeof PF . obj . listing . show _load _more == typeof undefined ) {
PF . obj . listing . show _load _more = visible _loading ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) [ ( visible _loading ? "add" : "remove" ) + "Class" ] ( "visibility-hidden" ) ;
$ ( PF . obj . listing . selectors . content _listing _load _more , $content _listing ) [ ( PF . obj . listing . show _load _more ? "show" : "hide" ) ] ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var State = History . getState ( ) ;
if ( State . data && typeof State . data . scrollTop !== "undefined" ) {
if ( $ ( window ) . scrollTop ( ) !== State . data . scrollTop ) {
//$(window).scrollTop(State.data.scrollTop);
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof callback == "function" ) {
callback ( ) ;
}
} )
} ) ;
} ;
PF . fn . listing . removeLoader = function ( obj ) {
var remove = [ PF . obj . listing . selectors . content _listing _load _more , PF . obj . listing . selectors . content _listing _loading ] ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( PF . obj . listing . selectors . content _listing _pagination , $content _listing ) . is ( "[data-type=endless]" ) ) {
remove . push ( PF . obj . listing . selectors . content _listing _pagination ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ . each ( remove , function ( i , v ) {
$ ( v , obj ) . remove ( ) ;
} ) ;
} ;
PF . fn . listing . queryString = {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock the querystring values from initial load
stock _load : function ( ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $content _listing = $ ( PF . obj . listing . selectors . content _listing _visible ) ,
params = PF . fn . deparam ( $content _listing . data ( "params" ) ) ;
2018-04-17 21:25:26 +00:00
2017-11-09 19:02:18 +00:00
PF . obj . listing . params _hidden = typeof $content _listing . data ( "params-hidden" ) !== "undefined" ? PF . fn . deparam ( $content _listing . data ( "params-hidden" ) ) : null ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof PF . obj . listing . query _string . action == "undefined" ) {
PF . obj . listing . query _string . action = $content _listing . data ( "action" ) || "list" ;
}
if ( typeof PF . obj . listing . query _string . list == "undefined" ) {
PF . obj . listing . query _string . list = $content _listing . data ( "list" ) ;
}
if ( typeof PF . obj . listing . query _string . sort == "undefined" ) {
if ( typeof params !== "undefined" && typeof params . sort !== "undefined" ) {
PF . obj . listing . query _string . sort = params . sort ;
} else {
PF . obj . listing . query _string . sort = $ ( ":visible" + PF . obj . listing . selectors . sort ) . data ( "sort" ) ;
}
}
if ( typeof PF . obj . listing . query _string . page == "undefined" ) {
PF . obj . listing . query _string . page = 1 ;
}
$content _listing . data ( "page" , PF . obj . listing . query _string . page ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock the real ajaxed hrefs for ajax loads
$ ( PF . obj . listing . selectors . content _listing + "[data-load=ajax]" ) . each ( function ( ) {
var $sortable _switch = $ ( "[data-tab=" + $ ( this ) . attr ( "id" ) + "]" + PF . obj . listing . selectors . sort ) ;
var dataParams = PF . fn . deparam ( $ ( this ) . data ( "params" ) ) ,
dataParamsHidden = PF . fn . deparam ( $ ( this ) . data ( "params-hidden" ) ) ,
params = {
q : dataParams && dataParams . q ? dataParams . q : null ,
list : $ ( this ) . data ( "list" ) ,
sort : $sortable _switch . exists ( ) ? $sortable _switch . data ( "sort" ) : ( dataParams && dataParams . sort ? dataParams . sort : null ) ,
page : dataParams && dataParams . page ? dataParams . page : 1
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( dataParamsHidden && dataParamsHidden . list ) {
delete params . list ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( var k in params ) {
if ( ! params [ k ] ) delete params [ k ] ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// The additional params setted in data-params=""
for ( var k in params ) {
if ( /action|list|sort|page/ . test ( k ) == false ) {
PF . obj . listing . query _string [ k ] = params [ k ] ;
}
}
2018-04-17 21:25:26 +00:00
2017-11-09 19:02:18 +00:00
if ( typeof PF . obj . listing . params _hidden !== typeof undefined ) {
// The additional params setted in data-hidden-params=""
for ( var k in PF . obj . listing . params _hidden ) {
if ( /action|list|sort|page/ . test ( k ) == false ) {
PF . obj . listing . query _string [ k ] = PF . obj . listing . params _hidden [ k ] ;
}
2016-08-18 20:39:31 +00:00
}
2017-11-09 19:02:18 +00:00
PF . obj . listing . query _string [ 'params_hidden' ] = PF . obj . listing . params _hidden ;
PF . obj . listing . params _hidden [ 'params_hidden' ] = null ; // Add this key for legacy, params_hidden v3.9.0 intro*
2016-08-18 20:39:31 +00:00
}
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock new querystring values for initial ajax call
stock _new : function ( ) {
var $content _listing = $ ( PF . obj . listing . selectors . content _listing _visible ) ,
params = PF . fn . deparam ( $content _listing . data ( "params" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $content _listing . data ( "offset" ) ) {
PF . obj . listing . query _string . offset = $content _listing . data ( "offset" ) ;
} else {
delete PF . obj . listing . query _string . offset ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . query _string . action = $content _listing . data ( "action" ) || "list" ;
PF . obj . listing . query _string . list = $content _listing . data ( "list" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof params !== "undefined" && typeof params . sort !== "undefined" ) {
PF . obj . listing . query _string . sort = params . sort ;
} else {
PF . obj . listing . query _string . sort = $ ( ":visible" + PF . obj . listing . selectors . sort ) . data ( "sort" ) ;
}
PF . obj . listing . query _string . page = 1 ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Stock querystring values for static tab change
stock _current : function ( ) {
this . stock _new ( ) ;
PF . obj . listing . query _string . page = $ ( PF . obj . listing . selectors . content _listing _visible ) . data ( "page" ) ;
}
} ;
// Initial load -> Stock the current querystring
PF . fn . listing . queryString . stock _load ( ) ;
PF . fn . listing . ajax = function ( ) {
if ( PF . obj . listing . calling == true ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . calling = true ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $content _listing = $ ( PF . obj . listing . selectors . content _listing _visible ) ,
$pad _content _listing = $ ( PF . obj . listing . selectors . pad _content , $content _listing ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( PF . obj . listing . selectors . content _listing _load _more , $content _listing ) . hide ( ) ;
$ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) . removeClass ( "visibility-hidden" ) . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . XHR = $ . ajax ( {
type : "POST" ,
data : $ . param ( $ . extend ( { } , PF . obj . listing . query _string , $ . ajaxSettings . data ) )
} ) . complete ( function ( XHR ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var response = XHR . responseJSON ;
var removePagination = function ( ) {
$ ( PF . obj . listing . selectors . content _listing _loading + "," + PF . obj . listing . selectors . content _listing _pagination + ":not([data-visibility=visible])" , $content _listing ) . remove ( ) ;
} ,
setEmptyTemplate = function ( ) {
$content _listing . data ( "empty" , "true" ) . html ( PF . obj . listing . template . empty ) ;
$ ( "[data-content=list-selection][data-tab=" + $content _listing . attr ( "id" ) + "]" ) . addClass ( "disabled" ) ;
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( XHR . readyState == 4 && typeof response !== "undefined" ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "[data-content=list-selection][data-tab=" + $content _listing . attr ( "id" ) + "]" ) . removeClass ( "disabled" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Bad Request Bad Request what you gonna do when they come for ya?
if ( XHR . status !== 200 ) {
// This is here to inherit the emptys
var response _output = typeof response . error !== "undefined" && typeof response . error . message !== "undefined" ? response . error . message : "Bad request" ;
PF . fn . growl . call ( "Error: " + response _output ) ;
2018-04-17 21:25:26 +00:00
$content _listing . data ( "load" , "" ) ;
2016-08-18 20:39:31 +00:00
}
// Empty HTML
if ( ( typeof response . html == "undefined" || response . html == "" ) && $ ( PF . obj . listing . selectors . list _item , $content _listing ) . length == 0 ) {
setEmptyTemplate ( ) ;
}
// End of the line
if ( typeof response . html == "undefined" || response . html == "" ) {
removePagination ( ) ;
PF . obj . listing . calling = false ;
if ( typeof PF . fn . listing _end == "function" ) {
PF . fn . listing _end ( ) ;
}
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Listing stuff
$content _listing . data ( {
"load" : "" ,
"page" : PF . obj . listing . query _string . page
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var url _object = $ . extend ( { } , PF . obj . listing . query _string ) ;
2017-11-09 19:02:18 +00:00
for ( var k in PF . obj . listing . params _hidden ) {
2016-08-18 20:39:31 +00:00
if ( typeof url _object [ k ] !== "undefined" ) {
delete url _object [ k ] ;
}
}
delete url _object [ "action" ] ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
for ( var k in url _object ) {
if ( ! url _object [ k ] ) delete url _object [ k ] ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// get the fancy URL with scrollTop attached
if ( document . URL . indexOf ( "?" + $ . param ( url _object ) ) == - 1 ) {
var url = window . location . href ;
url = url . split ( "?" ) [ 0 ] . replace ( /\/$/ , "" ) + "/?" + $ . param ( url _object ) ;
if ( window . location . hash ) {
url = url . replace ( window . location . hash , '' ) ;
}
History . pushState ( { pushed : "pagination" , scrollTop : $ ( window ) . scrollTop ( ) } , document . title , url ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "a[data-tab=" + $content _listing . attr ( "id" ) + "]" ) . attr ( "href" , document . URL ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$pad _content _listing . append ( response . html ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . listing . show ( response , function ( ) {
$ ( PF . obj . listing . selectors . content _listing _loading , $content _listing ) . addClass ( "visibility-hidden" ) ;
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} else {
// Network error, abort or something similar
PF . obj . listing . calling = false ;
$content _listing . data ( "load" , "" ) ;
removePagination ( ) ;
if ( $ ( PF . obj . listing . selectors . list _item , $content _listing ) . length == 0 ) {
setEmptyTemplate ( ) ;
}
if ( XHR . readyState !== 0 ) {
PF . fn . growl . call ( PF . fn . _s ( "An error occurred. Please try again later." ) ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof PF . fn . listing . ajax . callback == "function" ) {
PF . fn . listing . ajax . callback ( XHR ) ;
}
} ) ;
} ;
PF . fn . listing . columnizerQueue = function ( ) {
$ ( PF . obj . listing . selectors . content _listing + ":hidden" ) . data ( "queued" , true ) ;
} ;
PF . fn . listing . refresh = function ( animation _time ) {
PF . fn . listing . columnizer ( true , animation _time , false ) ;
$ ( PF . obj . listing . selectors . list _item ) . show ( ) ;
} ;
// Peafowl's masonry approach... Just because godlike.
var width = $ ( window ) . width ( ) ;
PF . fn . listing . columnizer = function ( forced , animation _time , hard _forced ) {
var device _to _columns = { // default
phone : 1 ,
phablet : 3 ,
tablet : 4 ,
laptop : 5 ,
desktop : 6 ,
largescreen : 7 ,
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof forced !== "boolean" ) var forced = false ;
if ( typeof PF . obj . listing . mode == "undefined" ) forced = true ;
if ( typeof hard _forced !== "boolean" ) {
var hard _forced = false ,
default _hard _forced = true ;
} else {
var default _hard _forced = false ;
}
if ( ! hard _forced && default _hard _forced ) {
if ( width !== $ ( window ) . width ( ) || forced ) {
hard _forced = true ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof animation _time == typeof undefined ) var animation _time = PF . obj . config . animation . normal ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
//animation_time = 0;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $container = $ ( "#content-listing-tabs" ) . exists ( ) ? $ ( PF . obj . listing . selectors . content _listing _visible , "#content-listing-tabs" ) : $ ( PF . obj . listing . selectors . content _listing ) ,
$pad _content _listing = $ ( PF . obj . listing . selectors . pad _content , $container ) ,
list _mode = "responsive" ,
$list _item = $ ( forced || hard _forced ? PF . obj . listing . selectors . list _item : PF . obj . listing . selectors . list _item + ":not(.jsly)" , $container ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$container . addClass ( "jsly" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Get the device columns from global config
if ( typeof PF . obj . config . listing . device _to _columns !== "undefined" ) {
device _to _columns = $ . extend ( { } , device _to _columns , PF . obj . config . listing . device _to _columns ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Get the device columns from the dom
if ( $container . data ( "device-columns" ) ) {
device _to _columns = $ . extend ( { } , device _to _columns , $container . data ( "device-columns" ) ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . mode = list _mode ;
PF . obj . listing . device = PF . fn . getDeviceName ( ) ;
if ( ! $list _item . exists ( ) ) return ;
if ( typeof $container . data ( "columns" ) !== "undefined" && ! forced && ! hard _forced ) {
PF . obj . listing . columns = $container . data ( "columns" ) ;
PF . obj . listing . columns _number = $container . data ( "columns" ) . length - 1 ;
PF . obj . listing . current _column = $container . data ( "current_column" ) ;
} else {
var $list _item _1st = $list _item . first ( ) ;
$list _item _1st . css ( "width" , "" ) ;
PF . obj . listing . columns = new Array ( ) ;
PF . obj . listing . columns _number = device _to _columns [ PF . fn . getDeviceName ( ) ] ;
for ( i = 0 ; i < PF . obj . listing . columns _number ; i ++ ) {
PF . obj . listing . columns [ i + 1 ] = 0 ;
}
PF . obj . listing . current _column = 1 ;
}
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
var special _margin = PF . obj . listing . columns _number == 1 ? "-10px" : "" ;
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
$ ( "#tabbed-content-group" ) . css ( { marginLeft : special _margin , marginRight : special _margin } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$container . removeClass ( "small-cols" ) . addClass ( PF . obj . listing . columns _number > 6 ? "small-cols" : "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$pad _content _listing . css ( "width" , "100%" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var delay = 0 ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$list _item . each ( function ( index ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . addClass ( "jsly" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $list _item _img = $ ( ".list-item-image" , this ) ,
$list _item _src = $ ( ".list-item-image img" , this ) ,
$list _item _thumbs = $ ( ".list-item-thumbs" , this ) ,
isJslyLoaded = $list _item _src . hasClass ( "jsly-loaded" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$list _item _src . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( hard _forced ) {
$ ( this ) . css ( { top : "" , left : "" , height : "" , position : "" } ) ;
$list _item _img . css ( { maxHeight : "" , height : "" } ) ;
$list _item _src . removeClass ( "jsly" ) . css ( { width : "" , height : "" } ) . parent ( ) . css ( {
marginLeft : "" ,
marginTop : ""
} ) ;
$ ( "li" , $list _item _thumbs ) . css ( { width : "" , height : "" } ) ;
}
var width _responsive = PF . obj . listing . columns _number == 1 ? "100%" : parseInt ( ( 1 / PF . obj . listing . columns _number ) * ( $container . width ( ) - ( 10 * ( PF . obj . listing . columns _number - 1 ) ) ) + "px" ) ;
$ ( this ) . css ( "width" , width _responsive ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . obj . listing . current _column > PF . obj . listing . columns _number ) {
PF . obj . listing . current _column = 1
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this ) . attr ( "data-col" , PF . obj . listing . current _column ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $list _item _src . exists ( ) ) {
var empty = true ;
$list _item _src = $ ( ".image-container .empty" , this ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var already _shown = $ ( this ) . is ( ":visible" ) ;
$list _item . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var isFixed = $list _item _img . hasClass ( "fixed-size" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var image = {
w : parseInt ( $list _item _src . attr ( "width" ) ) ,
h : parseInt ( $list _item _src . attr ( "height" ) )
} ;
image . ratio = image . w / image . h ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
//$list_item_src.removeAttr("width height"); // para fixed
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( hard _forced && PF . obj . listing . columns _number > 1 ) {
$list _item _src . css ( { width : "auto" , height : "auto" } ) ;
$ ( ".image-container:not(.list-item-avatar-cover)" , this ) . css ( { width : "" , height : "auto" } ) ;
} else {
if ( image . w > $container . width ( ) ) {
$ ( ".image-container:not(.list-item-avatar-cover)" , this ) . css ( image . ratio < 1 ? { maxWidth : "100%" , height : "auto" } : { height : "100%" , width : "auto" } ) ;
$list _item _src . css ( image . ratio < 1 ? { maxWidth : "100%" , height : "auto" } : { height : "100%" , width : "auto" } ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Meet the minHeight?
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( empty || ( $list _item _img . css ( "min-height" ) && ! $list _item _src . hasClass ( "jsly" ) ) ) {
var list _item _img _min _height = parseInt ( $list _item _img . css ( "height" ) ) ,
col = {
w : $ ( this ) . width ( ) ,
h : isFixed ? $ ( this ) . width ( ) : null
} ,
magicWidth = Math . min ( image . w , image . w < col . w ? image . w : col . w ) ;
if ( isFixed ) {
$list _item _img . css ( { height : col . w } ) ; // Sets the item container height
if ( image . ratio <= 3 && ( image . ratio > 1 || image . ratio == 1 ) ) { // Landscape or square
image . h = Math . min ( image . h , image . w < col . w ? image . w : col . w ) ;
image . w = image . h * image . ratio ;
} else { // Portrait
image . w = magicWidth ;
image . h = image . w / image . ratio ;
}
var list _item _img _min _h = parseInt ( $list _item _img . css ( "min-height" ) ) ;
$list _item _img . css ( "min-height" , 0 ) ;
} else { // Fluid height
image . w = magicWidth ;
if ( image . ratio >= 3 || image . ratio < 1 || image . ratio == 1 ) { // Portrait or square
image . h = image . w / image . ratio ;
} else { // Landscape
image . h = Math . min ( image . h , image . w ) ;
image . w = image . h * image . ratio ;
}
if ( empty ) {
image . h = col . w ;
}
$list _item _img . css ( { height : image . h } ) ; // Fill some gaps
}
$list _item _src . css ( { width : image . w , height : image . h } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $list _item _src . width ( ) == 0 ) {
$list _item _src . css ( { width : magicWidth , height : magicWidth / image . ratio } ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( ".image-container" , this ) . is ( ".list-item-avatar-cover" ) ) {
$list _item _src . css ( isFixed ? { width : "auto" , height : "100%" } : { width : "100%" , height : "auto" } ) ;
}
if ( $list _item _src . height ( ) !== 0 && ( $list _item _img . height ( ) > $list _item _src . height ( ) || isFixed ) ) {
$list _item _src . parent ( ) . css ( {
"marginTop" : ( $list _item _img . outerHeight ( ) - $list _item _src . height ( ) ) / 2
} ) ;
}
if ( $list _item _img . width ( ) < $list _item _src . width ( ) ) {
$list _item _src . parent ( ) . css ( {
"marginLeft" : - ( ( $list _item _src . outerWidth ( ) - $list _item _img . width ( ) ) / 2 ) + "px"
} ) ;
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
var list _item _src _pitfall _x = Math . max ( $list _item _src . position ( ) . left * 2 , 0 ) ,
list _item _src _pitfall _y = Math . max ( $list _item _src . position ( ) . top * 2 , 0 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Do we need upscale? It is safe to upscale?
if ( PF . obj . listing . columns _number > 6 && ( list _item _src _pitfall _x > 0 || list _item _src _pitfall _y > 0 ) ) {
var pitfall _ratio _x = list _item _src _pitfall _x / $list _item _img . width ( ) ,
pitfall _ratio _y = list _item _src _pitfall _y / $list _item _img . height ( ) ,
pitfall = { } ;
if ( pitfall _ratio _x <= . 25 && pitfall _ratio _y <= . 25 ) {
if ( pitfall _ratio _x > pitfall _ratio _y ) {
pitfall . width = list _item _src _pitfall _x + $list _item _img . width ( ) ;
pitfall . height = pitfall . width / image . ratio ;
} else {
pitfall . height = list _item _src _pitfall _y + $list _item _src . height ( ) ;
pitfall . width = pitfall . height * image . ratio ;
}
$list _item _src . css ( pitfall ) ;
$list _item _src . parent ( ) . css ( {
"marginLeft" : - ( ( $list _item _src . width ( ) - $list _item _img . width ( ) ) / 2 ) ,
"marginTop" : 0
} ) ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $list _item _thumbs . exists ( ) ) {
$ ( "li" , $list _item _thumbs ) . css ( { width : 100 / $ ( "li" , $list _item _thumbs ) . length + "%" } ) . css ( { height : $ ( "li" , $list _item _thumbs ) . width ( ) } ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! already _shown ) {
$list _item . hide ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
//$pad_content_listing.css("visibility", "visible");
if ( ! $list _item _src . hasClass ( "jsly" ) && $ ( this ) . is ( ":hidden" ) ) {
$ ( this ) . css ( 'top' , "100%" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . columns [ PF . obj . listing . current _column ] += $ ( this ) . outerHeight ( true ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . obj . listing . columns _number == 1 ) {
$ ( this ) . removeClass ( "position-absolute" ) ;
} else {
if ( $ ( this ) . is ( ":animated" ) ) {
animation _time = 0 ;
}
$ ( this ) . addClass ( "position-absolute" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var new _left = $ ( this ) . outerWidth ( true ) * ( PF . obj . listing . current _column - 1 ) ;
var must _change _left = parseInt ( $ ( this ) . css ( "left" ) ) != new _left ;
if ( must _change _left ) {
animate _grid = true ;
$ ( this ) . animate ( {
left : new _left
} , animation _time ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var new _top = PF . obj . listing . columns [ PF . obj . listing . current _column ] - $ ( this ) . outerHeight ( true ) ;
if ( parseInt ( $ ( this ) . css ( "top" ) ) != new _top ) {
animate _grid = true ;
$ ( this ) . animate ( {
top : new _top
} , animation _time ) ;
if ( must _change _left ) {
delay = 1 ;
}
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( already _shown ) {
$list _item . show ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! isJslyLoaded ) {
$list _item _src . addClass ( "jsly" ) . hide ( ) . imagesLoaded ( function ( i ) {
$ ( i . elements ) . show ( ) . addClass ( "jsly-loaded" ) ;
} ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Fill the shortest column (fluid view only)
if ( ! isFixed ) {
var minCol , minH , currentH ;
for ( var i = 1 ; i <= PF . obj . listing . columns _number ; i ++ ) {
currentH = PF . obj . listing . columns [ i ] ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof minH == "undefined" ) {
minH = currentH ;
minCol = i ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( PF . obj . listing . columns [ i ] == 0 ) {
minCol = i ;
break ;
}
if ( currentH < minH ) {
minH = PF . obj . listing . columns [ i ] ;
minCol = i ;
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . current _column = minCol ;
} else {
PF . obj . listing . current _column ++ ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$container . data ( { "columns" : PF . obj . listing . columns , "current_column" : PF . obj . listing . current _column } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var content _listing _height = 0 ;
$ . each ( PF . obj . listing . columns , function ( i , v ) {
if ( v > content _listing _height ) {
content _listing _height = v ;
}
} ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( content _listing _height > 10 ) {
content _listing _height -= 10 ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . listing . width = $container . width ( ) ;
if ( typeof PF . obj . listing . height !== typeof undefined ) {
var old _listing _height = PF . obj . listing . height ;
2018-04-17 21:25:26 +00:00
}
2016-08-18 20:39:31 +00:00
PF . obj . listing . height = content _listing _height ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var do _listing _h _resize = typeof old _listing _height !== typeof undefined && old _listing _height !== PF . obj . listing . height ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! do _listing _h _resize ) {
$pad _content _listing . height ( content _listing _height ) ;
PF . fn . list _fluid _width ( ) ;
}
2018-04-17 21:25:26 +00:00
// Magic!
2016-08-18 20:39:31 +00:00
if ( do _listing _h _resize ) {
$pad _content _listing . height ( old _listing _height ) ;
setTimeout ( function ( ) {
$pad _content _listing . animate ( { height : content _listing _height } , animation _time , function ( ) {
PF . fn . list _fluid _width ( ) ;
} ) ;
} , animation _time * delay ) ;
}
2018-04-17 21:25:26 +00:00
$container . data ( "list-mode" , PF . obj . listing . mode ) ;
2016-08-18 20:39:31 +00:00
$ ( PF . obj . listing . selectors . content _listing _visible ) . data ( "queued" , false ) ;
2016-11-06 02:19:47 +00:00
2016-08-18 20:39:31 +00:00
} ;
/ * *
* PEAFOWL LOADERS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . fn . loading = {
spin : {
small : { lines : 11 , length : 0 , width : 3 , radius : 7 , speed : 1 , trail : 45 , blocksize : 20 } , // 20x20
normal : { lines : 11 , length : 0 , width : 5 , radius : 10 , speed : 1 , trail : 45 , blocksize : 30 } , // 30x30
big : { lines : 11 , length : 0 , width : 7 , radius : 13 , speed : 1 , trail : 45 , blocksize : 40 } , // 40x40
huge : { lines : 11 , length : 0 , width : 9 , radius : 16 , speed : 1 , trail : 45 , blocksize : 50 } // 50x50
} ,
2016-10-17 21:16:45 +00:00
inline : function ( $target , options ) {
2016-08-18 20:39:31 +00:00
if ( typeof $target == "undefined" ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target instanceof jQuery == false ) {
var $target = $ ( $target ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var defaultoptions = {
size : "normal" ,
color : $ ( "body" ) . css ( "color" ) ,
center : false ,
position : "absolute" ,
shadow : false ,
valign : "top"
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof options == "undefined" ) {
options = defaultoptions ;
} else {
for ( var k in defaultoptions ) {
if ( typeof options [ k ] == "undefined" ) {
options [ k ] = defaultoptions [ k ] ;
}
}
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var size = PF . fn . loading . spin [ options . size ] ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . loading . spin [ options . size ] . color = options . color ;
PF . fn . loading . spin [ options . size ] . shadow = options . shadow ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$target . html ( '<span class="loading-indicator"></span>' + ( typeof options . message !== "undefined" ? '<span class="loading-text">' + options . message + '</span>' : '' ) ) . css ( { "line-height" : PF . fn . loading . spin [ options . size ] . blocksize + "px" } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".loading-indicator" , $target ) . css ( { width : PF . fn . loading . spin [ options . size ] . blocksize , height : PF . fn . loading . spin [ options . size ] . blocksize } ) . spin ( PF . fn . loading . spin [ options . size ] ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( options . center ) {
$ ( ".loading-indicator" , $target . css ( "textAlign" , "center" ) ) . css ( {
position : options . position ,
top : "50%" ,
left : "50%" ,
marginTop : - ( PF . fn . loading . spin [ options . size ] . blocksize / 2 ) ,
marginLeft : - ( PF . fn . loading . spin [ options . size ] . blocksize / 2 )
} ) ;
}
if ( options . valign == "center" ) {
$ ( ".loading-indicator,.loading-text" , $target ) . css ( "marginTop" , ( $target . height ( ) - PF . fn . loading . spin [ options . size ] . blocksize ) / 2 + "px" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( ".spinner" , $target ) . css ( { top : PF . fn . loading . spin [ options . size ] . blocksize / 2 + "px" , left : PF . fn . loading . spin [ options . size ] . blocksize / 2 + "px" } ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ,
fullscreen : function ( ) {
$ ( "body" ) . append ( '<div class="fullscreen" id="pf-fullscreen-loader"><div class="fullscreen-loader black-bkg"><span class="loading-txt">' + PF . fn . _s ( "loading" ) + '</span></div></div>' ) ;
$ ( ".fullscreen-loader" , "#pf-fullscreen-loader" ) . spin ( PF . fn . loading . spin . huge ) ;
$ ( "#pf-fullscreen-loader" ) . css ( "opacity" , 1 ) ;
} ,
destroy : function ( $target ) {
var $loader _fs = $ ( "#pf-fullscreen-loader" ) ,
$loader _os = $ ( "#pf-onscreen-loader" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $target == "fullscreen" ) $target = $loader _fs ;
if ( $target == "onscreen" ) $target = $loader _os ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof $target !== "undefined" ) {
$target . remove ( ) ;
} else {
$loader _fs . remove ( ) ;
$loader _os . remove ( ) ;
}
}
} ;
/ * *
* PEAFOWL FORM HELPERS
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
jQuery . fn . disableForm = function ( ) {
$ ( this ) . data ( "disabled" , true ) ;
$ ( ":input" , this ) . each ( function ( ) {
$ ( this ) . attr ( "disabled" , true ) ;
} ) ;
return this ;
} ;
jQuery . fn . enableForm = function ( ) {
$ ( this ) . data ( "disabled" , false ) ;
$ ( ":input" , this ) . removeAttr ( "disabled" ) ;
return this ;
} ;
/ * *
* PEAFOWL FOLLOW SCROLL
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
PF . obj . follow _scroll = {
Y : 0 ,
y : 0 ,
$node : $ ( ".follow-scroll" ) ,
node _h : 0 ,
2016-11-06 02:19:47 +00:00
base _h : $ ( ".follow-scroll" ) . outerHeight ( ) ,
set : function ( reset ) {
if ( reset ) {
PF . obj . follow _scroll . base _h = $ ( ".follow-scroll" ) . outerHeight ( ) ;
}
2016-08-18 20:39:31 +00:00
var exists = PF . obj . follow _scroll . $node . closest ( ".follow-scroll-wrapper" ) . exists ( ) ;
if ( exists ) {
PF . obj . follow _scroll . $node . closest ( ".follow-scroll-wrapper" ) . css ( "position" , "static" ) ;
}
PF . obj . follow _scroll . y = PF . obj . follow _scroll . $node . exists ( ) ? PF . obj . follow _scroll . $node . offset ( ) . top : null ;
PF . obj . follow _scroll . node _h = PF . obj . follow _scroll . $node . outerHeight ( ) ;
if ( exists ) {
PF . obj . follow _scroll . $node . closest ( ".follow-scroll-wrapper" ) . css ( "position" , "" ) ;
}
} ,
checkDocumentHeight : function ( ) {
var lastHeight = document . body . clientHeight , newHeight , timer ;
( function run ( ) {
newHeight = document . body . clientHeight ;
2016-11-06 02:19:47 +00:00
if ( lastHeight != newHeight ) {
2016-08-18 20:39:31 +00:00
PF . obj . follow _scroll . set ( ) ;
2016-11-06 02:19:47 +00:00
}
2016-08-18 20:39:31 +00:00
lastHeight = newHeight ;
timer = setTimeout ( run , 200 ) ;
} ) ( ) ;
}
} ;
PF . obj . follow _scroll . set ( ) ;
2016-11-06 02:19:47 +00:00
//PF.obj.follow_scroll.checkDocumentHeight();
2016-08-18 20:39:31 +00:00
2016-11-06 02:19:47 +00:00
PF . obj . follow _scroll . process = function ( forced ) {
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
if ( forced ) {
PF . obj . follow _scroll . node _h = PF . obj . follow _scroll . base _h ;
}
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
if ( ! PF . obj . follow _scroll . $node . exists ( ) ) return ; // Nothing to do here
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $parent = PF . obj . follow _scroll . $node . closest ( "[data-content=follow-scroll-parent]" ) ;
if ( ! $parent . exists ( ) ) {
$parent = PF . obj . follow _scroll . $node . closest ( ".content-width" ) ;
}
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
var $wrapper = PF . obj . follow _scroll . $node . closest ( '.follow-scroll-wrapper' ) ;
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
var top = PF . obj . follow _scroll . node _h ;
var cond = $ ( window ) . scrollTop ( ) > PF . obj . follow _scroll . y - top ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( "#top-bar" ) . css ( "position" ) !== "fixed" ) {
PF . obj . follow _scroll . Y -= $ ( window ) . scrollTop ( ) ;
if ( PF . obj . follow _scroll . Y < 0 ) PF . obj . follow _scroll . Y = 0 ;
cond = cond && $ ( window ) . scrollTop ( ) > PF . obj . follow _scroll . y ;
}
2016-11-06 02:19:47 +00:00
2016-08-18 20:39:31 +00:00
if ( ( cond && $wrapper . hasClass ( "position-fixed" ) ) || ( ! cond && ! $wrapper . hasClass ( "position-fixed" ) ) ) {
return ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $wrapper . exists ( ) ) {
PF . obj . follow _scroll . $node . wrapAll ( '<div class="follow-scroll-wrapper" />' ) ;
$wrapper = PF . obj . follow _scroll . $node . closest ( '.follow-scroll-wrapper' ) ;
}
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
$wrapper . css ( "min-height" , PF . obj . follow _scroll . node _h ) ;
2018-04-17 21:25:26 +00:00
2016-11-06 02:19:47 +00:00
PF . obj . follow _scroll . Y = $ ( "#top-bar" ) . outerHeight ( true ) + parseFloat ( $ ( "#top-bar" ) . css ( "top" ) ) ;
2016-08-18 20:39:31 +00:00
2016-11-06 02:19:47 +00:00
if ( cond ) {
var placeholderHeight = PF . obj . follow _scroll . node _h ;
2016-08-18 20:39:31 +00:00
$wrapper
. addClass ( "position-fixed" )
. css ( { top : PF . obj . follow _scroll . Y } ) ;
if ( ! $wrapper . next ( ) . is ( ".follow-scroll-placeholder" ) ) {
2016-11-06 02:19:47 +00:00
$wrapper . after ( $ ( '<div class="follow-scroll-placeholder" />' ) . css ( "min-height" , placeholderHeight ) ) ;
2016-08-18 20:39:31 +00:00
} else {
$wrapper . parent ( ) . find ( ".follow-scroll-placeholder" ) . show ( ) ;
}
} else {
2016-11-06 02:19:47 +00:00
$wrapper . removeClass ( "position-fixed" ) . css ( { top : "" , width : "" , minHeight : "" } ) ;
2016-08-18 20:39:31 +00:00
$wrapper . parent ( ) . find ( ".follow-scroll-placeholder" ) . hide ( ) ;
}
2016-11-06 02:19:47 +00:00
2016-08-18 20:39:31 +00:00
$ ( "[data-show-on=follow-scroll]" ) [ ( cond ? "remove" : "add" ) + "Class" ] ( "hidden soft-hidden" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $ ( "html" ) . data ( "top-bar-box-shadow-prevent" ) ) {
$ ( "html" ) [ ( cond ? "add" : "remove" ) + "Class" ] ( "top-bar-box-shadow-none" ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . obj . follow _scroll . $node [ ( cond ? "add" : "remove" ) + "Class" ] ( "content-width" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ;
PF . fn . isDevice = function ( device ) {
if ( typeof device == "object" ) {
var device = '.' + device . join ( ",." ) ;
} else {
var device = '.' + device ;
}
return $ ( "html" ) . is ( device ) ;
} ;
PF . fn . getDeviceName = function ( ) {
var current _device ;
$ . each ( PF . obj . devices , function ( i , v ) {
if ( PF . fn . isDevice ( v ) ) {
current _device = v ;
return true ;
}
} ) ;
return current _device ;
} ;
PF . fn . topMenu = {
vars : {
$button : $ ( "[data-action=top-bar-menu-full]" , "#top-bar" ) ,
menu : "#menu-fullscreen" ,
speed : PF . obj . config . animation . fast ,
menu _top : ( parseInt ( $ ( "#top-bar" ) . outerHeight ( ) ) + parseInt ( $ ( "#top-bar" ) . css ( "top" ) ) + parseInt ( $ ( "#top-bar" ) . css ( "margin-top" ) ) + parseInt ( $ ( "#top-bar" ) . css ( "margin-bottom" ) ) - parseInt ( $ ( "#top-bar" ) . css ( "border-bottom-width" ) ) ) + "px"
} ,
show : function ( speed ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( "body" ) . is ( ":animated" ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof speed == "undefined" ) {
var speed = this . vars . speed ;
}
this . vars . $button . addClass ( "current" ) ;
2016-11-06 02:19:47 +00:00
//$("html").addClass("menu-fullscreen-visible");
2016-08-18 20:39:31 +00:00
$ ( "#top-bar" ) . css ( "position" , "fixed" ) . append ( $ ( "<div/>" , {
id : "menu-fullscreen" ,
"class" : "touch-scroll" ,
html : $ ( '<ul/>' , {
html : $ ( ".top-bar-left" ) . html ( ) + $ ( ".top-bar-right" ) . html ( )
} )
} ) . css ( {
borderTopWidth : this . vars . menu _top ,
left : "-100%" ,
//height: $(window).height(), // aca
} ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $menu = $ ( this . vars . menu ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "li.phone-hide, li > .top-btn-text, li > .top-btn-text > span, li > a > .top-btn-text > span" , $menu ) . each ( function ( ) {
$ ( this ) . removeClass ( "phone-hide" ) ;
} ) ;
$ ( "[data-action=top-bar-menu-full]" , $menu ) . remove ( ) ;
$ ( ".btn.black, .btn.default, .btn.blue, .btn.green, .btn.orange, .btn.red, .btn.transparent" , $menu ) . removeClass ( "btn black default blue green orange red transparent" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
setTimeout ( function ( ) {
$menu . css ( { transform : "translate(100%, 0)" } ) ;
} , 1 ) ;
setTimeout ( function ( ) {
$ ( "html" ) . css ( { backgroundColor : "" } ) ;
} , this . vars . speed ) ;
} ,
hide : function ( speed ) {
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( $ ( "body" ) . is ( ":animated" ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( ! $ ( this . vars . menu ) . is ( ":visible" ) ) return ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
if ( typeof speed == "undefined" ) {
var speed = this . vars . speed ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "#top-bar" ) . css ( "position" , "" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
this . vars . $button . removeClass ( "current" ) ;
2016-11-06 02:19:47 +00:00
//$("html").removeClass("menu-fullscreen-visible");
2016-08-18 20:39:31 +00:00
var $menu = $ ( this . vars . menu ) ;
$menu . css ( {
transform : "none"
} ) ;
setTimeout ( function ( ) {
$menu . remove ( ) ;
} , speed ) ;
}
} ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
/ * *
* PEAFOWL FULL SCREEN VIEWER
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
// nota: incompleto
/ * $ ( " i m g " , " . l i s t - i t e m - i m a g e " ) . c l i c k ( f u n c t i o n ( e ) {
if ( ! $ ( this ) . closest ( ".fullscreen-enable" ) . exists ( ) ) return ;
e . preventDefault ( ) ;
$ ( this ) . closest ( PF . obj . listing . selectors . content _listing ) . find ( ".navigation-pointer" ) . removeClass ( "navigation-pointer" ) ;
$ ( this ) . closest ( ".list-item" ) . addClass ( "navigation-pointer" ) ;
PF . fn . fullscreen . content ( $ ( this ) . attr ( "src" ) . replace ( "_e" , "" ) ) ;
PF . fn . fullscreen . call ( ) ;
} ) ;
$ ( "a" , ".fullscreen-viewer-navigation" ) . click ( function ( ) {
if ( $ ( this ) . hasClass ( "disabled" ) ) return ;
$current _navigation _pointer = $ ( ".navigation-pointer" , PF . obj . listing . selectors . content _listing ) ;
switch ( $ ( this ) . attr ( "data-action" ) ) {
case "prev" :
if ( ! $current _navigation _pointer . prev ( ) . exists ( ) ) return ;
$target = $current _navigation _pointer . prev ( ) ;
break ;
case "next" :
if ( ! $current _navigation _pointer . next ( ) . exists ( ) ) return ;
$target = $current _navigation _pointer . next ( ) ;
break ;
case "close" :
$ ( this ) . closest ( ".fullscreen" ) . hide ( ) . find ( ".fullscreen-viewer-content img" ) . attr ( "src" , "" ) ;
$ ( "body" ) . removeClass ( "overflow-hidden" ) ;
return ;
break ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$current _navigation _pointer . removeClass ( "navigation-pointer" ) ;
$target . addClass ( "navigation-pointer" ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$new _navigation _pointer = $ ( ".navigation-pointer" , PF . obj . listing . selectors . content _listing ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . fullscreen . content ( $new _navigation _pointer . find ( ".list-item-image img" ) . attr ( "src" ) . replace ( "_e" , "" ) ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
PF . fn . fullscreen . call ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
} ) ; * /
/ *
PF . fn . fullscreen = {
selectors : {
fullscreen : ".fullscreen" ,
container : "#fullscreen-viewer" ,
content : ".fullscreen-viewer-content" ,
top : ".fullscreen-viewer-top" ,
nav : ".fullscreen-viewer-navigation"
} ,
call : function ( ) {
PF . fn . fullscreen . update _nav ( ) ;
if ( ! $ ( this . str . fullscreen ) . is ( ":visible" ) ) {
$ ( this . str . fullscreen ) . show ( ) ;
$ ( "body" ) . addClass ( "overflow-hidden" ) ;
PF . fn . fullscreen . size ( ) ;
}
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this . str . content ) . hide ( ) . imagesLoaded ( function ( ) {
PF . fn . fullscreen . size ( ) ;
$ ( this ) . show ( ) ;
} ) ;
} ,
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
// Fix the fullscreen size
size : function ( ) {
if ( ! $ ( this . str . container ) . is ( ":visible" ) ) return ;
$ ( "img" , this . str . content ) . css ( "margin-top" , 0 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var window _height = $ ( window ) . height ( ) ;
$ ( this . str . fullscreen ) . height ( window _height ) ;
var fullscreen _content _height = window _height - ( $ ( this . str . top ) . length > 0 ? $ ( this . str . top ) . height ( ) : 0 ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( this . str . content ) . height ( fullscreen _content _height ) . show ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
var $fullscreen _content _img = $ ( "img" , this . str . content ) ,
fullscreen _content _img _height = $ ( "img" , this . str . content ) . height ( ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$ ( "img" , this . str . content ) . css ( "margin-top" , ( fullscreen _content _height - fullscreen _content _img _height ) / 2 ) ;
} ,
update _nav : function ( ) {
var $navigation _pointer = $ ( ".navigation-pointer" ) ,
$next _button _nav = $ ( this . str . nav ) . find ( '[data-action="next"]' ) ,
$prev _button _nav = $ ( this . str . nav ) . find ( '[data-action="prev"]' ) ;
2018-04-17 21:25:26 +00:00
2016-08-18 20:39:31 +00:00
$next _button _nav . toggleClass ( "disabled" , ! $navigation _pointer . next ( ) . exists ( ) ) ;
2018-04-17 21:25:26 +00:00
$prev _button _nav . toggleClass ( "disabled" , ! $navigation _pointer . prev ( ) . exists ( ) ) ;
2016-08-18 20:39:31 +00:00
} ,
content : function ( src ) {
$ ( "img" , this . str . content ) . remove ( ) ;
$ ( ".img-src-parent" , this . str . content ) . append ( '<img src="js/' + src + '" alt="">' ) ;
} ,
next : function ( ) {
} ,
prev : function ( ) {
}
} ;
* /
/ * *
* JQUERY PLUGINS ( strictly needed plugins )
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
* /
// http://phpjs.org/functions/sprintf/
function sprintf ( ) { var e = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g ; var t = arguments ; var n = 0 ; var r = t [ n ++ ] ; var i = function ( e , t , n , r ) { if ( ! n ) { n = " " } var i = e . length >= t ? "" : ( new Array ( 1 + t - e . length >>> 0 ) ) . join ( n ) ; return r ? e + i : i + e } ; var s = function ( e , t , n , r , s , o ) { var u = r - e . length ; if ( u > 0 ) { if ( n || ! s ) { e = i ( e , r , o , n ) } else { e = e . slice ( 0 , t . length ) + i ( "" , u , "0" , true ) + e . slice ( t . length ) } } return e } ; var o = function ( e , t , n , r , o , u , a ) { var f = e >>> 0 ; n = n && f && { 2 : "0b" , 8 : "0" , 16 : "0x" } [ t ] || "" ; e = n + i ( f . toString ( t ) , u || 0 , "0" , false ) ; return s ( e , n , r , o , a ) } ; var u = function ( e , t , n , r , i , o ) { if ( r != null ) { e = e . slice ( 0 , r ) } return s ( e , "" , t , n , i , o ) } ; var a = function ( e , r , a , f , l , c , h ) { var p , d , v , m , g ; if ( e === "%%" ) { return "%" } var y = false ; var b = "" ; var w = false ; var E = false ; var S = " " ; var x = a . length ; for ( var T = 0 ; a && T < x ; T ++ ) { switch ( a . charAt ( T ) ) { case " " : b = " " ; break ; case "+" : b = "+" ; break ; case "-" : y = true ; break ; case "'" : S = a . charAt ( T + 1 ) ; break ; case "0" : w = true ; S = "0" ; break ; case "#" : E = true ; break } } if ( ! f ) { f = 0 } else if ( f === "*" ) { f = + t [ n ++ ] } else if ( f . charAt ( 0 ) == "*" ) { f = + t [ f . slice ( 1 , - 1 ) ] } else { f = + f } if ( f < 0 ) { f = - f ; y = true } if ( ! isFinite ( f ) ) { throw new Error ( "sprintf: (minimum-)width must be finite" ) } if ( ! c ) { c = "fFeE" . indexOf ( h ) > - 1 ? 6 : h === "d" ? 0 : undefined } else if ( c === "*" ) { c = + t [ n ++ ] } else if ( c . charAt ( 0 ) == "*" ) { c = + t [ c . slice ( 1 , - 1 ) ] } else { c = + c } g = r ? t [ r . slice ( 0 , - 1 ) ] : t [ n ++ ] ; switch ( h ) { case "s" : return u ( String ( g ) , y , f , c , w , S ) ; case "c" : return u ( String . fromCharCode ( + g ) , y , f , c , w ) ; case "b" : return o ( g , 2 , E , y , f , c , w ) ; case "o" : return o ( g , 8 , E , y , f , c , w ) ; case "x" : return o ( g , 16 , E , y , f , c , w ) ; case "X" : return o ( g , 16 , E , y , f , c , w ) . toUpperCase ( ) ; case "u" : return o ( g , 10 , E , y , f , c , w ) ; case "i" : case "d" : p = + g || 0 ; p = Math . round ( p - p % 1 ) ; d = p < 0 ? "-" : b ; g = d + i ( String ( Math . abs ( p ) ) , c , "0" , false ) ; return s ( g , d , y , f , w ) ; case "e" : case "E" : case "f" : case "F" : case "g" : case "G" : p = + g ; d = p < 0 ? "-" : b ; v = [ "toExponential" , "toFixed" , "toPrecision" ] [ "efg" . indexOf ( h . toLowerCase ( ) ) ] ; m = [ "toString" , "toUpperCase" ] [ "eEfFgG" . indexOf ( h ) % 2 ] ; g = d + Math . abs ( p ) [ v ] ( c ) ; return s ( g , d , y , f , w ) [ m ] ( ) ; default : return e } } ; return r . replace ( e , a ) } ;
/ * !
* imagesLoaded PACKAGED v4 . 1.0
* JavaScript is all like "You images are done yet or what?"
* MIT License
* /
! function ( t , e ) { "function" == typeof define && define . amd ? define ( "ev-emitter/ev-emitter" , e ) : "object" == typeof module && module . exports ? module . exports = e ( ) : t . EvEmitter = e ( ) } ( this , function ( ) { function t ( ) { } var e = t . prototype ; return e . on = function ( t , e ) { if ( t && e ) { var i = this . _events = this . _events || { } , n = i [ t ] = i [ t ] || [ ] ; return - 1 == n . indexOf ( e ) && n . push ( e ) , this } } , e . once = function ( t , e ) { if ( t && e ) { this . on ( t , e ) ; var i = this . _onceEvents = this . _onceEvents || { } , n = i [ t ] = i [ t ] || [ ] ; return n [ e ] = ! 0 , this } } , e . off = function ( t , e ) { var i = this . _events && this . _events [ t ] ; if ( i && i . length ) { var n = i . indexOf ( e ) ; return - 1 != n && i . splice ( n , 1 ) , this } } , e . emitEvent = function ( t , e ) { var i = this . _events && this . _events [ t ] ; if ( i && i . length ) { var n = 0 , o = i [ n ] ; e = e || [ ] ; for ( var r = this . _onceEvents && this . _onceEvents [ t ] ; o ; ) { var s = r && r [ o ] ; s && ( this . off ( t , o ) , delete r [ o ] ) , o . apply ( this , e ) , n += s ? 0 : 1 , o = i [ n ] } return this } } , t } ) , function ( t , e ) { "use strict" ; "function" == typeof define && define . amd ? define ( [ "ev-emitter/ev-emitter" ] , function ( i ) { return e ( t , i ) } ) : "object" == typeof module && module . exports ? module . exports = e ( t , require ( "ev-emitter" ) ) : t . imagesLoaded = e ( t , t . EvEmitter ) } ( window , function ( t , e ) { function i ( t , e ) { for ( var i in e ) t [ i ] = e [ i ] ; return t } function n ( t ) { var e = [ ] ; if ( Array . isArray ( t ) ) e = t ; else if ( "number" == typeof t . length ) for ( var i = 0 ; i < t . length ; i ++ ) e . push ( t [ i ] ) ; else e . push ( t ) ; return e } function o ( t , e , r ) { return this instanceof o ? ( "string" == typeof t && ( t = document . querySelectorAll ( t ) ) , this . elements = n ( t ) , this . options = i ( { } , this . options ) , "function" == typeof e ? r = e : i ( this . options , e ) , r && this . on ( "always" , r ) , this . getImages ( ) , h && ( this . jqDeferred = new h . Deferred ) , void setTimeout ( function ( ) { this . check ( ) } . bind ( this ) ) ) : new o ( t , e , r ) } function r ( t ) { this . img = t } function s ( t , e ) { this . url = t , this . element = e , this . img = new Image } var h = t . jQuery , a = t . console ; o . prototype = Object . create ( e . prototype ) , o . prototype . options = { } , o . prototype . getImages = function ( ) { this . images = [ ] , this . elements . forEach ( this . addElementImages , this ) } , o . prototype . addElementImages = function ( t ) { "IMG" == t . nodeName && this . addImage ( t ) , this . options . background === ! 0 && this . addElementBackgroundImages ( t ) ; var e = t . nodeType ; if ( e && d [ e ] ) { for ( var i = t . querySelectorAll ( "img" ) , n = 0 ; n < i . length ; n ++ ) { var o = i [ n ] ; this . addImage ( o ) } if ( "string" == typeof this . options . background ) { var r = t . querySelectorAll ( this . options . background ) ; for ( n = 0 ; n < r . length ; n ++ ) { var s = r [ n ] ; this . addElementBackgroundImages ( s ) } } } } ; var d = { 1 : ! 0 , 9 : ! 0 , 11 : ! 0 } ; return o . prototype . addElementBackgroundImages = function ( t ) { var e = getComputedStyle ( t ) ; if ( e ) for ( var i = /url\((['"])?(.*?)\1\)/gi , n = i . exec ( e . backgroundImage ) ; null !== n ; ) { var o = n && n [ 2 ] ; o && this . addBackground ( o , t ) , n = i . exec ( e . backgroundImage ) } } , o . prototype . addImage = function ( t ) { var e = new r ( t ) ; this . images . push ( e ) } , o . prototype . addBackground = function ( t , e ) { var i = new s ( t , e ) ; this . images . push ( i ) } , o . prototype . check = function ( ) { function t ( t , i , n ) { setTimeout ( function ( ) { e . progress ( t , i , n ) } ) } var e = this ; return this . progressedCount = 0 , this . hasAnyBroken = ! 1 , this . images . length ? void this . images . forEach ( function ( e ) { e . once ( "progress" , t ) , e . check ( ) } ) : void this . complete ( ) } , o . prototype . progress = function ( t , e , i ) { this . progressedCount ++ , this . hasAnyBroken = this . hasAnyBroken || ! t . isLoaded , this . emitEvent ( "progress" , [ this , t , e ] ) , this . jqDeferred && this . jqDeferred . notify && this . jqDeferred . notify ( this , t ) , this . progressedCount == this . images . length && this . complete ( ) , this . options . debug && a && a . log ( "progress: " + i , t , e ) } , o . prototype . complete = function ( ) { var t = this . hasAnyBroken ? "fail" : "done" ; if ( this . isComplete = ! 0 , this . emitEvent ( t , [ this ] ) , this . emitEvent ( "always" , [ this ] ) , this . jqDeferred ) { var e = this . hasAnyBroken ? "reject" : "resolve" ; this . jqDeferred [ e ] ( this ) } } , r . prototype = Object . create ( e . prototype ) , r . prototype . check = function ( ) { var t = this . getIsImageComplete ( ) ; return t ? void this . confirm ( 0 !== this . img . naturalWidth , "naturalWidth" ) : ( this . proxyImage = new Image , this . proxyImage . addEventListener ( "load" , this ) , this . proxyImage . addEventListener ( "error" , this ) , this . img . addEventListener ( "load" , this ) , this . img . addEventListener ( "error" , this ) , void ( this . proxyImage . src = this . img . src ) ) } , r . prototype . getIsImageComplete = function ( ) { return this . img . complete && void 0 !== this . img . naturalWidth } , r . prototype . confirm = function (
/ * *
* TipTip
* Copyright 2010 Drew Wilson
* code . drewwilson . com / entry / tiptip - jquery - plugin
*
* Version 1.3 ( modified ) - Updated : Jun . 23 , 2011
* http : //drew.tenderapp.com/discussions/tiptip/70-updated-tiptip-with-new-features
*
* This TipTip jQuery plug - in is dual licensed under the MIT and GPL licenses :
* http : //www.opensource.org/licenses/mit-license.php
* http : //www.gnu.org/licenses/gpl.html
* /
( function ( $ ) { $ . fn . tipTip = function ( options ) { var defaults = { activation : "hover" , keepAlive : false , maxWidth : "200px" , edgeOffset : 6 , defaultPosition : "bottom" , delay : 400 , fadeIn : 200 , fadeOut : 200 , attribute : "title" , content : false , enter : function ( ) { } , afterEnter : function ( ) { } , exit : function ( ) { } , afterExit : function ( ) { } , cssClass : "" } ; if ( $ ( "#tiptip_holder" ) . length <= 0 ) { var tiptip _holder = $ ( '<div id="tiptip_holder"></div>' ) ; var tiptip _content = $ ( '<div id="tiptip_content"></div>' ) ; var tiptip _arrow = $ ( '<div id="tiptip_arrow"></div>' ) ; $ ( "body" ) . append ( tiptip _holder . html ( tiptip _content ) . prepend ( tiptip _arrow . html ( '<div id="tiptip_arrow_inner"></div>' ) ) ) } else { var tiptip _holder = $ ( "#tiptip_holder" ) ; var tiptip _content = $ ( "#tiptip_content" ) ; var tiptip _arrow = $ ( "#tiptip_arrow" ) } return this . each ( function ( ) { var org _elem = $ ( this ) , data = org _elem . data ( "tipTip" ) , opts = data && data . options || $ . extend ( defaults , options ) , callback _data = { holder : tiptip _holder , content : tiptip _content , arrow : tiptip _arrow , options : opts } ; if ( data ) { switch ( options ) { case "show" : active _tiptip ( ) ; break ; case "hide" : deactive _tiptip ( ) ; break ; case "destroy" : org _elem . unbind ( ".tipTip" ) . removeData ( "tipTip" ) ; break } } else { var timeout = false ; org _elem . data ( "tipTip" , { options : opts } ) ; if ( opts . activation == "hover" ) { org _elem . bind ( "mouseenter.tipTip" , function ( ) { active _tiptip ( ) } ) . bind ( "mouseleave.tipTip" , function ( ) { if ( ! opts . keepAlive ) { deactive _tiptip ( ) } else { tiptip _holder . one ( "mouseleave.tipTip" , function ( ) { deactive _tiptip ( ) } ) } } ) } else { if ( opts . activation == "focus" ) { org _elem . bind ( "focus.tipTip" , function ( ) { active _tiptip ( ) } ) . bind ( "blur.tipTip" , function ( ) { deactive _tiptip ( ) } ) } else { if ( opts . activation == "click" ) { org _elem . bind ( "click.tipTip" , function ( e ) { e . preventDefault ( ) ; active _tiptip ( ) ; return false } ) . bind ( "mouseleave.tipTip" , function ( ) { if ( ! opts . keepAlive ) { deactive _tiptip ( ) } else { tiptip _holder . one ( "mouseleave.tipTip" , function ( ) { deactive _tiptip ( ) } ) } } ) } else { if ( opts . activation == "manual" ) { } } } } } function active _tiptip ( ) { if ( opts . enter . call ( org _elem , callback _data ) === false ) { return } var org _title ; if ( opts . content ) { org _title = $ . isFunction ( opts . content ) ? opts . content . call ( org _elem , callback _data ) : opts . content } else { org _title = opts . content = org _elem . attr ( opts . attribute ) ; org _elem . removeAttr ( opts . attribute ) } if ( ! org _title ) { return } tiptip _content . html ( org _title ) ; tiptip _holder . hide ( ) . removeAttr ( "class" ) . css ( { margin : "0px" , "max-width" : opts . maxWidth } ) ; if ( opts . cssClass ) { tiptip _holder . addClass ( opts . cssClass ) } tiptip _arrow . removeAttr ( "style" ) ; var top = parseInt ( org _elem . offset ( ) [ "top" ] ) , left = parseInt ( org _elem . offset ( ) [ "left" ] ) , org _width = parseInt ( org _elem . outerWidth ( ) ) , org _height = parseInt ( org _elem . outerHeight ( ) ) , tip _w = tiptip _holder . outerWidth ( ) , tip _h = tiptip _holder . outerHeight ( ) , w _compare = Math . round ( ( org _width - tip _w ) / 2 ) , h _compare = Math . round ( ( org _height - tip _h ) / 2 ) , marg _left = Math . round ( left + w _compare ) , marg _top = Math . round ( top + org _height + opts . edgeOffset ) , t _class = "" , arrow _top = "" , arrow _left = Math . round ( tip _w - 12 ) / 2 ; if ( opts . defaultPosition == "bottom" ) { t _class = "_bottom" } else { if ( opts . defaultPosition == "top" ) { t _class = "_top" } else { if ( opts . defaultPosition == "left" ) { t _class = "_left" } else { if ( opts . defaultPosition == "right" ) { t _class = "_right" } } } } var right _compare = ( w _compare + left ) < parseInt ( $ ( window ) . scrollLeft ( ) ) , left _compare = ( tip _w + left ) > parseInt ( $ ( window ) . width ( ) ) ; if ( ( right _compare && w _compare < 0 ) || ( t _class == "_right" && ! left _compare ) || ( t _class == "_left" && left < ( tip _w + opts . edgeOffset + 5 ) ) ) { t _class = "_right" ; arrow _top = Math . round ( tip _h - 13 ) / 2 ; arrow _left = - 12 ; marg _left = Math . round ( left + org _width + opts . edgeOffset ) ; marg _top = Math . round ( top + h _compare ) } else { if ( ( left _compare && w _compare < 0 ) || ( t _class == "_left" && ! right _compare ) ) { t _class = "_left" ; arrow _top = Math . round ( tip _h - 13 ) / 2 ; arrow _left = Math . round ( tip _w ) ; marg _left = Math . round ( left - ( tip _w + opts . edgeOffset + 5 ) ) ; marg _top = Math . round ( top + h _compare ) } } var top _compare = ( top + org _height + opts . edgeOffset + tip _h + 8 ) > parseInt ( $ ( window ) . height ( ) + $ ( window ) . scrollTop ( ) ) , bottom _compare = ( ( top + org _height ) - ( opts . edgeOffset + tip _h + 8 ) ) < 0 ; if ( top _compare || ( t _class == "_bottom" && top _compare ) || ( t _class == "_top" && ! bottom _compare ) ) { if ( t _class == "_top" || t _class == "_bottom" ) { t _class = "_top" } else { t _class = t _class + "_top" } arrow _top = ti
/ * *
* jQuery UI Touch Punch 0.2 . 2
* Copyright 2011 , Dave Furfero
* Dual licensed under the MIT or GPL Version 2 licenses .
* Depends : jquery . ui . widget jquery . ui . mouse
* /
( function ( b ) { b . support . touch = "ontouchend" in document ; if ( ! b . support . touch ) { return ; } var c = b . ui . mouse . prototype , e = c . _mouseInit , a ; function d ( g , h ) { if ( g . originalEvent . touches . length > 1 ) { return ; } g . preventDefault ( ) ; var i = g . originalEvent . changedTouches [ 0 ] , f = document . createEvent ( "MouseEvents" ) ; f . initMouseEvent ( h , true , true , window , 1 , i . screenX , i . screenY , i . clientX , i . clientY , false , false , false , false , 0 , null ) ; g . target . dispatchEvent ( f ) ; } c . _touchStart = function ( g ) { var f = this ; if ( a || ! f . _mouseCapture ( g . originalEvent . changedTouches [ 0 ] ) ) { return ; } a = true ; f . _touchMoved = false ; d ( g , "mouseover" ) ; d ( g , "mousemove" ) ; d ( g , "mousedown" ) ; } ; c . _touchMove = function ( f ) { if ( ! a ) { return ; } this . _touchMoved = true ; d ( f , "mousemove" ) ; } ; c . _touchEnd = function ( f ) { if ( ! a ) { return ; } d ( f , "mouseup" ) ; d ( f , "mouseout" ) ; if ( ! this . _touchMoved ) { d ( f , "click" ) ; } a = false ; } ; c . _mouseInit = function ( ) { var f = this ; f . element . bind ( "touchstart" , b . proxy ( f , "_touchStart" ) ) . bind ( "touchmove" , b . proxy ( f , "_touchMove" ) ) . bind ( "touchend" , b . proxy ( f , "_touchEnd" ) ) ; e . call ( f ) ; } ; } ) ( jQuery ) ;
/ * *
* fileOverview TouchSwipe - jQuery Plugin
* version 1.6 . 5
* /
( function ( a ) { if ( typeof define === "function" && define . amd && define . amd . jQuery ) { define ( [ "jquery" ] , a ) } else { a ( jQuery ) } } ( function ( e ) { var o = "left" , n = "right" , d = "up" , v = "down" , c = "in" , w = "out" , l = "none" , r = "auto" , k = "swipe" , s = "pinch" , x = "tap" , i = "doubletap" , b = "longtap" , A = "horizontal" , t = "vertical" , h = "all" , q = 10 , f = "start" , j = "move" , g = "end" , p = "cancel" , a = "ontouchstart" in window , y = "TouchSwipe" ; var m = { fingers : 1 , threshold : 75 , cancelThreshold : null , pinchThreshold : 20 , maxTimeThreshold : null , fingerReleaseThreshold : 250 , longTapThreshold : 500 , doubleTapThreshold : 200 , swipe : null , swipeLeft : null , swipeRight : null , swipeUp : null , swipeDown : null , swipeStatus : null , pinchIn : null , pinchOut : null , pinchStatus : null , click : null , tap : null , doubleTap : null , longTap : null , triggerOnTouchEnd : true , triggerOnTouchLeave : false , allowPageScroll : "auto" , fallbackToMouseEvents : true , excludedElements : "label, button, input, select, textarea, a, .noSwipe" } ; e . fn . swipe = function ( D ) { var C = e ( this ) , B = C . data ( y ) ; if ( B && typeof D === "string" ) { if ( B [ D ] ) { return B [ D ] . apply ( this , Array . prototype . slice . call ( arguments , 1 ) ) } else { e . error ( "Method " + D + " does not exist on jQuery.swipe" ) } } else { if ( ! B && ( typeof D === "object" || ! D ) ) { return u . apply ( this , arguments ) } } return C } ; e . fn . swipe . defaults = m ; e . fn . swipe . phases = { PHASE _START : f , PHASE _MOVE : j , PHASE _END : g , PHASE _CANCEL : p } ; e . fn . swipe . directions = { LEFT : o , RIGHT : n , UP : d , DOWN : v , IN : c , OUT : w } ; e . fn . swipe . pageScroll = { NONE : l , HORIZONTAL : A , VERTICAL : t , AUTO : r } ; e . fn . swipe . fingers = { ONE : 1 , TWO : 2 , THREE : 3 , ALL : h } ; function u ( B ) { if ( B && ( B . allowPageScroll === undefined && ( B . swipe !== undefined || B . swipeStatus !== undefined ) ) ) { B . allowPageScroll = l } if ( B . click !== undefined && B . tap === undefined ) { B . tap = B . click } if ( ! B ) { B = { } } B = e . extend ( { } , e . fn . swipe . defaults , B ) ; return this . each ( function ( ) { var D = e ( this ) ; var C = D . data ( y ) ; if ( ! C ) { C = new z ( this , B ) ; D . data ( y , C ) } } ) } function z ( a0 , aq ) { var av = ( a || ! aq . fallbackToMouseEvents ) , G = av ? "touchstart" : "mousedown" , au = av ? "touchmove" : "mousemove" , R = av ? "touchend" : "mouseup" , P = av ? null : "mouseleave" , az = "touchcancel" ; var ac = 0 , aL = null , Y = 0 , aX = 0 , aV = 0 , D = 1 , am = 0 , aF = 0 , J = null ; var aN = e ( a0 ) ; var W = "start" ; var T = 0 ; var aM = null ; var Q = 0 , aY = 0 , a1 = 0 , aa = 0 , K = 0 ; var aS = null ; try { aN . bind ( G , aJ ) ; aN . bind ( az , a5 ) } catch ( ag ) { e . error ( "events not supported " + G + "," + az + " on jQuery.swipe" ) } this . enable = function ( ) { aN . bind ( G , aJ ) ; aN . bind ( az , a5 ) ; return aN } ; this . disable = function ( ) { aG ( ) ; return aN } ; this . destroy = function ( ) { aG ( ) ; aN . data ( y , null ) ; return aN } ; this . option = function ( a8 , a7 ) { if ( aq [ a8 ] !== undefined ) { if ( a7 === undefined ) { return aq [ a8 ] } else { aq [ a8 ] = a7 } } else { e . error ( "Option " + a8 + " does not exist on jQuery.swipe.options" ) } return null } ; function aJ ( a9 ) { if ( ax ( ) ) { return } if ( e ( a9 . target ) . closest ( aq . excludedElements , aN ) . length > 0 ) { return } var ba = a9 . originalEvent ? a9 . originalEvent : a9 ; var a8 , a7 = a ? ba . touches [ 0 ] : ba ; W = f ; if ( a ) { T = ba . touches . length } else { a9 . preventDefault ( ) } ac = 0 ; aL = null ; aF = null ; Y = 0 ; aX = 0 ; aV = 0 ; D = 1 ; am = 0 ; aM = af ( ) ; J = X ( ) ; O ( ) ; if ( ! a || ( T === aq . fingers || aq . fingers === h ) || aT ( ) ) { ae ( 0 , a7 ) ; Q = ao ( ) ; if ( T == 2 ) { ae ( 1 , ba . touches [ 1 ] ) ; aX = aV = ap ( aM [ 0 ] . start , aM [ 1 ] . start ) } if ( aq . swipeStatus || aq . pinchStatus ) { a8 = L ( ba , W ) } } else { a8 = false } if ( a8 === false ) { W = p ; L ( ba , W ) ; return a8 } else { ak ( true ) } return null } function aZ ( ba ) { var bd = ba . originalEvent ? ba . originalEvent : ba ; if ( W === g || W === p || ai ( ) ) { return } var a9 , a8 = a ? bd . touches [ 0 ] : bd ; var bb = aD ( a8 ) ; aY = ao ( ) ; if ( a ) { T = bd . touches . length } W = j ; if ( T == 2 ) { if ( aX == 0 ) { ae ( 1 , bd . touches [ 1 ] ) ; aX = aV = ap ( aM [ 0 ] . start , aM [ 1 ] . start ) } else { aD ( bd . touches [ 1 ] ) ; aV = ap ( aM [ 0 ] . end , aM [ 1 ] . end ) ; aF = an ( aM [ 0 ] . end , aM [ 1 ] . end ) } D = a3 ( aX , aV ) ; am = Math . abs ( aX - aV ) } if ( ( T === aq . fingers || aq . fingers === h ) || ! a || aT ( ) ) { aL = aH ( bb . start , bb . end ) ; ah ( ba , aL ) ; ac = aO ( bb . start , bb . end ) ; Y = aI ( ) ; aE ( aL , ac ) ; if ( aq . swipeStatus || aq . pinchStatus ) { a9 = L ( bd , W ) } if ( ! aq . triggerOnTouchEnd || aq . triggerOnTouchLeave ) { var a7 = true ; if ( aq . triggerOnTouchLeave ) { var bc = aU ( this ) ; a7 = B ( bb . end , bc ) } if ( ! aq . triggerOnTouchEnd && a7 ) { W = ay ( j ) } else { if ( aq . triggerOnTouchLeave && ! a7 ) { W = ay ( g ) } } if ( W == p || W == g ) { L ( bd , W ) } } } else { W = p ; L ( bd , W ) } if ( a9 === false ) { W = p ; L ( bd , W ) } } function I ( a7 ) { var a8 = a7 . originalEvent ; if ( a ) { if ( a8 . touches . length > 0 ) { C ( ) ; return true } } if ( ai ( ) ) { T = aa } a7 . preventDefault ( ) ; aY = ao ( ) ; Y = aI ( ) ; if ( a6 ( ) ) { W = p ; L ( a8 , W ) } else { if ( aq . triggerOnTouchEnd || ( aq . triggerOnTouchEnd == false && W === j ) ) { W = g ; L ( a8 ,
2016-11-06 02:19:47 +00:00
/ *
* JavaScript Load Image v2 . 7.0 * ( added S . originalWidth and S . originalHeight )
2016-08-18 20:39:31 +00:00
* https : //github.com/blueimp/JavaScript-Load-Image
2016-11-06 02:19:47 +00:00
*
2016-08-18 20:39:31 +00:00
* Copyright 2011 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
2016-11-06 02:19:47 +00:00
! function ( e ) { "use strict" ; function t ( e , i , a ) { var o , r = document . createElement ( "img" ) ; if ( r . onerror = function ( o ) { return t . onerror ( r , o , e , i , a ) } , r . onload = function ( o ) { return t . onload ( r , o , e , i , a ) } , t . isInstanceOf ( "Blob" , e ) || t . isInstanceOf ( "File" , e ) ) o = r . _objectURL = t . createObjectURL ( e ) ; else { if ( "string" != typeof e ) return ! 1 ; o = e , a && a . crossOrigin && ( r . crossOrigin = a . crossOrigin ) } return o ? ( r . src = o , r ) : t . readFile ( e , function ( e ) { var t = e . target ; t && t . result ? r . src = t . result : i && i ( e ) } ) } function i ( e , i ) { ! e . _objectURL || i && i . noRevoke || ( t . revokeObjectURL ( e . _objectURL ) , delete e . _objectURL ) } var a = window . createObjectURL && window || window . URL && URL . revokeObjectURL && URL || window . webkitURL && webkitURL ; t . isInstanceOf = function ( e , t ) { return Object . prototype . toString . call ( t ) === "[object " + e + "]" } , t . transform = function ( e , i , a , o , r ) { a ( t . scale ( e , i , r ) , r ) } , t . onerror = function ( e , t , a , o , r ) { i ( e , r ) , o && o . call ( e , t ) } , t . onload = function ( e , a , o , r , n ) { i ( e , n ) , r && t . transform ( e , n , r , o , { } ) } , t . transformCoordinates = function ( ) { } , t . getTransformedOptions = function ( e , t ) { var i , a , o , r , n = t . aspectRatio ; if ( ! n ) return t ; i = { } ; for ( a in t ) t . hasOwnProperty ( a ) && ( i [ a ] = t [ a ] ) ; return i . crop = ! 0 , o = e . naturalWidth || e . width , r = e . naturalHeight || e . height , o / r > n ? ( i . maxWidth = r * n , i . maxHeight = r ) : ( i . maxWidth = o , i . maxHeight = o / n ) , i } , t . renderImageToCanvas = function ( e , t , i , a , o , r , n , s , l , d ) { return e . getContext ( "2d" ) . drawImage ( t , i , a , o , r , n , s , l , d ) , e } , t . hasCanvasOption = function ( e ) { return e . canvas || e . crop || ! ! e . aspectRatio } , t . scale = function ( e , i , a ) { function o ( ) { var e = Math . max ( ( l || v ) / v , ( d || P ) / P ) ; e > 1 && ( v *= e , P *= e ) } function r ( ) { var e = Math . min ( ( n || v ) / v , ( s || P ) / P ) ; e < 1 && ( v *= e , P *= e ) } i = i || { } ; var n , s , l , d , u , c , f , g , h , m , p , S = document . createElement ( "canvas" ) , b = e . getContext || t . hasCanvasOption ( i ) && S . getContext , x = e . naturalWidth || e . width , y = e . naturalHeight || e . height , v = x , P = y ; S . originalWidth = x ; S . originalHeight = y ; if ( b && ( i = t . getTransformedOptions ( e , i , a ) , f = i . left || 0 , g = i . top || 0 , i . sourceWidth ? ( u = i . sourceWidth , void 0 !== i . right && void 0 === i . left && ( f = x - u - i . right ) ) : u = x - f - ( i . right || 0 ) , i . sourceHeight ? ( c = i . sourceHeight , void 0 !== i . bottom && void 0 === i . top && ( g = y - c - i . bottom ) ) : c = y - g - ( i . bottom || 0 ) , v = u , P = c ) , n = i . maxWidth , s = i . maxHeight , l = i . minWidth , d = i . minHeight , b && n && s && i . crop ? ( v = n , P = s , p = u / c - n / s , p < 0 ? ( c = s * u / n , void 0 === i . top && void 0 === i . bottom && ( g = ( y - c ) / 2 ) ) : p > 0 && ( u = n * c / s , void 0 === i . left && void 0 === i . right && ( f = ( x - u ) / 2 ) ) ) : ( ( i . contain || i . cover ) && ( l = n = n || l , d = s = s || d ) , i . cover ? ( r ( ) , o ( ) ) : ( o ( ) , r ( ) ) ) , b ) { if ( h = i . pixelRatio , h > 1 && ( S . style . width = v + "px" , S . style . height = P + "px" , v *= h , P *= h , S . getContext ( "2d" ) . scale ( h , h ) ) , m = i . downsamplingRatio , m > 0 && m < 1 && v < u && P < c ) for ( ; u * m > v ; ) S . width = u * m , S . height = c * m , t . renderImageToCanvas ( S , e , f , g , u , c , 0 , 0 , S . width , S . height ) , u = S . width , c = S . height , e = document . createElement ( "canvas" ) , e . width = u , e . height = c , t . renderImageToCanvas ( e , S , 0 , 0 , u , c , 0 , 0 , u , c ) ; return S . width = v , S . height = P , t . transformCoordinates ( S , i ) , t . renderImageToCanvas ( S , e , f , g , u , c , 0 , 0 , v , P ) } return e . width = v , e . height = P , e } , t . createObjectURL = function ( e ) { return ! ! a && a . createObjectURL ( e ) } , t . revokeObjectURL = function ( e ) { return ! ! a && a . revokeObjectURL ( e ) } , t . readFile = function ( e , t , i ) { if ( window . FileReader ) { var a = new FileReader ; if ( a . onload = a . onerror = t , i = i || "readAsDataURL" , a [ i ] ) return a [ i ] ( e ) , a } return ! 1 } , "function" == typeof define && define . amd ? define ( function ( ) { return t } ) : "object" == typeof module && module . exports ? module . exports = t : e . loadImage = t } ( window ) , function ( e ) { "use strict" ; "function" == typeof define && define . amd ? define ( [ "./load-image" ] , e ) : e ( "object" == typeof module && module . exports ? require ( "./load-image" ) : window . loadImage ) } ( function ( e ) { "use strict" ; var t = window . Blob && ( Blob . prototype . slice || Blob . prototype . webkitSlice || Blob . prototype . mozSlice ) ; e . blobSlice = t && function ( ) { var e = this . slice || this . webkitSlice || this . mozSlice ; return e . apply ( this , arguments ) } , e . metaDataParsers = { jpeg : { 65505 : [ ] } } , e . parseMetaData = function ( t , i , a , o ) { a = a || { } , o = o || { } ; var r = this , n = a . maxMetaDataSize || 262144 , s = ! ( window . DataView && t && t . size >= 12 && "image/jpeg" === t . type && e . blobSlice ) ; ! s && e . readFile ( e . blobSlice . call ( t , 0 , n ) , function ( t ) { if ( t . target . error ) return console . log ( t . target . error ) , void i ( o ) ; var n , s , l , d , u = t . target . result , c = new DataView ( u ) , f = 2 , g = c . byteLength - 4 , h = f ; if ( 65496 === c . getUint16 ( 0 ) ) { for ( ; f < g && ( n = c . get
2016-08-18 20:39:31 +00:00
/ * *
* History . js Core
* @ author Benjamin Arthur Lupton < contact @ balupton . com >
* @ copyright 2010 - 2011 Benjamin Arthur Lupton < contact @ balupton . com >
* @ license New BSD License < http : //creativecommons.org/licenses/BSD/>
* /
typeof JSON != "object" && ( JSON = { } ) , function ( ) { "use strict" ; function f ( e ) { return e < 10 ? "0" + e : e } function quote ( e ) { return escapable . lastIndex = 0 , escapable . test ( e ) ? '"' + e . replace ( escapable , function ( e ) { var t = meta [ e ] ; return typeof t == "string" ? t : "\\u" + ( "0000" + e . charCodeAt ( 0 ) . toString ( 16 ) ) . slice ( - 4 ) } ) + '"' : '"' + e + '"' } function str ( e , t ) { var n , r , i , s , o = gap , u , a = t [ e ] ; a && typeof a == "object" && typeof a . toJSON == "function" && ( a = a . toJSON ( e ) ) , typeof rep == "function" && ( a = rep . call ( t , e , a ) ) ; switch ( typeof a ) { case "string" : return quote ( a ) ; case "number" : return isFinite ( a ) ? String ( a ) : "null" ; case "boolean" : case "null" : return String ( a ) ; case "object" : if ( ! a ) return "null" ; gap += indent , u = [ ] ; if ( Object . prototype . toString . apply ( a ) === "[object Array]" ) { s = a . length ; for ( n = 0 ; n < s ; n += 1 ) u [ n ] = str ( n , a ) || "null" ; return i = u . length === 0 ? "[]" : gap ? "[\n" + gap + u . join ( ",\n" + gap ) + "\n" + o + "]" : "[" + u . join ( "," ) + "]" , gap = o , i } if ( rep && typeof rep == "object" ) { s = rep . length ; for ( n = 0 ; n < s ; n += 1 ) typeof rep [ n ] == "string" && ( r = rep [ n ] , i = str ( r , a ) , i && u . push ( quote ( r ) + ( gap ? ": " : ":" ) + i ) ) } else for ( r in a ) Object . prototype . hasOwnProperty . call ( a , r ) && ( i = str ( r , a ) , i && u . push ( quote ( r ) + ( gap ? ": " : ":" ) + i ) ) ; return i = u . length === 0 ? "{}" : gap ? "{\n" + gap + u . join ( ",\n" + gap ) + "\n" + o + "}" : "{" + u . join ( "," ) + "}" , gap = o , i } } typeof Date . prototype . toJSON != "function" && ( Date . prototype . toJSON = function ( e ) { return isFinite ( this . valueOf ( ) ) ? this . getUTCFullYear ( ) + "-" + f ( this . getUTCMonth ( ) + 1 ) + "-" + f ( this . getUTCDate ( ) ) + "T" + f ( this . getUTCHours ( ) ) + ":" + f ( this . getUTCMinutes ( ) ) + ":" + f ( this . getUTCSeconds ( ) ) + "Z" : null } , String . prototype . toJSON = Number . prototype . toJSON = Boolean . prototype . toJSON = function ( e ) { return this . valueOf ( ) } ) ; var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g , escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g , gap , indent , meta = { "\b" : "\\b" , " " : "\\t" , "\n" : "\\n" , "\f" : "\\f" , "\r" : "\\r" , '"' : '\\"' , "\\" : "\\\\" } , rep ; typeof JSON . stringify != "function" && ( JSON . stringify = function ( e , t , n ) { var r ; gap = "" , indent = "" ; if ( typeof n == "number" ) for ( r = 0 ; r < n ; r += 1 ) indent += " " ; else typeof n == "string" && ( indent = n ) ; rep = t ; if ( ! t || typeof t == "function" || typeof t == "object" && typeof t . length == "number" ) return str ( "" , { "" : e } ) ; throw new Error ( "JSON.stringify" ) } ) , typeof JSON . parse != "function" && ( JSON . parse = function ( text , reviver ) { function walk ( e , t ) { var n , r , i = e [ t ] ; if ( i && typeof i == "object" ) for ( n in i ) Object . prototype . hasOwnProperty . call ( i , n ) && ( r = walk ( i , n ) , r !== undefined ? i [ n ] = r : delete i [ n ] ) ; return reviver . call ( e , t , i ) } var j ; text = String ( text ) , cx . lastIndex = 0 , cx . test ( text ) && ( text = text . replace ( cx , function ( e ) { return "\\u" + ( "0000" + e . charCodeAt ( 0 ) . toString ( 16 ) ) . slice ( - 4 ) } ) ) ; if ( /^[\],:{}\s]*$/ . test ( text . replace ( /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g , "@" ) . replace ( /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g , "]" ) . replace ( /(?:^|:|,)(?:\s*\[)+/g , "" ) ) ) return j = eval ( "(" + text + ")" ) , typeof reviver == "function" ? walk ( { "" : j } , "" ) : j ; throw new SyntaxError ( "JSON.parse" ) } ) } ( ) , function ( e , t ) { "use strict" ; var n = e . History = e . History || { } , r = e . jQuery ; if ( typeof n . Adapter != "undefined" ) throw new Error ( "History.js Adapter has already been loaded..." ) ; n . Adapter = { bind : function ( e , t , n ) { r ( e ) . bind ( t , n ) } , trigger : function ( e , t , n ) { r ( e ) . trigger ( t , n ) } , extractEventData : function ( e , n , r ) { var i = n && n . originalEvent && n . originalEvent [ e ] || r && r [ e ] || t ; return i } , onDomLoad : function ( e ) { r ( e ) } } , typeof n . init != "undefined" && n . init ( ) } ( window ) , function ( e , t ) { "use strict" ; var n = e . document , r = e . setTimeout || r , i = e . clearTimeout || i , s = e . setInterval || s , o = e . History = e . History || { } ; if ( typeof o . initHtml4 != "undefined" ) throw new Error ( "History.js HTML4 Support has already been loaded..." ) ; o . initHtml4 = function ( ) { if ( typeof o . initHtml4 . initialized != "undefined" ) return ! 1 ; o . initHtml4 . initialized = ! 0 , o . enabled = ! 0 , o . savedHashes = [ ] , o . isLastHash = function ( e ) { var t = o . getHashByIndex ( ) , n ; return n = e === t , n } , o . isHashEqual = function ( e , t ) { return e = encodeURIComponent ( e ) . replace ( /%25/g , "%" ) , t = encodeURIComponent ( t ) . replace ( /%25/g , "%" ) , e === t } , o . saveHash = function ( e ) { return o . isLastHash ( e ) ? ! 1 : ( o . savedHashes . push ( e ) , ! 0 ) } , o . getHashByIndex = function ( e ) { var t = null ; return typeo
/ *
* jQuery Iframe Transport Plugin 1.7
* https : //github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011 , Sebastian Tschan
* https : //blueimp.net
*
* Licensed under the MIT license :
* http : //www.opensource.org/licenses/MIT
* /
/*jslint unparam: true, nomen: true */
/*global define, window, document */
( function ( factory ) { if ( typeof define === "function" && define . amd ) { define ( [ "jquery" ] , factory ) } else { factory ( window . jQuery ) } } ( function ( $ ) { var counter = 0 ; $ . ajaxTransport ( "iframe" , function ( options ) { if ( options . async ) { var form , iframe , addParamChar ; return { send : function ( _ , completeCallback ) { form = $ ( '<form style="display:none;"></form>' ) ; form . attr ( "accept-charset" , options . formAcceptCharset ) ; addParamChar = /\?/ . test ( options . url ) ? "&" : "?" ; if ( options . type === "DELETE" ) { options . url = options . url + addParamChar + "_method=DELETE" ; options . type = "POST" } else { if ( options . type === "PUT" ) { options . url = options . url + addParamChar + "_method=PUT" ; options . type = "POST" } else { if ( options . type === "PATCH" ) { options . url = options . url + addParamChar + "_method=PATCH" ; options . type = "POST" } } } counter += 1 ; iframe = $ ( '<iframe src="javascript:false;" name="iframe-transport-' + counter + '"></iframe>' ) . bind ( "load" , function ( ) { var fileInputClones , paramNames = $ . isArray ( options . paramName ) ? options . paramName : [ options . paramName ] ; iframe . unbind ( "load" ) . bind ( "load" , function ( ) { var response ; try { response = iframe . contents ( ) ; if ( ! response . length || ! response [ 0 ] . firstChild ) { throw new Error ( ) } } catch ( e ) { response = undefined } completeCallback ( 200 , "success" , { iframe : response } ) ; $ ( '<iframe src="javascript:false;"></iframe>' ) . appendTo ( form ) ; window . setTimeout ( function ( ) { form . remove ( ) } , 0 ) } ) ; form . prop ( "target" , iframe . prop ( "name" ) ) . prop ( "action" , options . url ) . prop ( "method" , options . type ) ; if ( options . formData ) { $ . each ( options . formData , function ( index , field ) { $ ( '<input type="hidden"/>' ) . prop ( "name" , field . name ) . val ( field . value ) . appendTo ( form ) } ) } if ( options . fileInput && options . fileInput . length && options . type === "POST" ) { fileInputClones = options . fileInput . clone ( ) ; options . fileInput . after ( function ( index ) { return fileInputClones [ index ] } ) ; if ( options . paramName ) { options . fileInput . each ( function ( index ) { $ ( this ) . prop ( "name" , paramNames [ index ] || options . paramName ) } ) } form . append ( options . fileInput ) . prop ( "enctype" , "multipart/form-data" ) . prop ( "encoding" , "multipart/form-data" ) } form . submit ( ) ; if ( fileInputClones && fileInputClones . length ) { options . fileInput . each ( function ( index , input ) { var clone = $ ( fileInputClones [ index ] ) ; $ ( input ) . prop ( "name" , clone . prop ( "name" ) ) ; clone . replaceWith ( input ) } ) } } ) ; form . append ( iframe ) . appendTo ( document . body ) } , abort : function ( ) { if ( iframe ) { iframe . unbind ( "load" ) . prop ( "src" , "javascript" . concat ( ":false;" ) ) } if ( form ) { form . remove ( ) } } } } } ) ; $ . ajaxSetup ( { converters : { "iframe text" : function ( iframe ) { return iframe && $ ( iframe [ 0 ] . body ) . text ( ) } , "iframe json" : function ( iframe ) { return iframe && $ . parseJSON ( $ ( iframe [ 0 ] . body ) . text ( ) ) } , "iframe html" : function ( iframe ) { return iframe && $ ( iframe [ 0 ] . body ) . html ( ) } , "iframe xml" : function ( iframe ) { var xmlDoc = iframe && iframe [ 0 ] ; return xmlDoc && $ . isXMLDoc ( xmlDoc ) ? xmlDoc : $ . parseXML ( ( xmlDoc . XMLDocument && xmlDoc . XMLDocument . xml ) || $ ( xmlDoc . body ) . html ( ) ) } , "iframe script" : function ( iframe ) { return iframe && $ . globalEval ( $ ( iframe [ 0 ] . body ) . text ( ) ) } } } ) } ) ) ;
/ * *
* Copyright ( c ) 2011 - 2013 Felix Gnass
* Licensed under the MIT license
* /
//fgnass.github.com/spin.js#v1.3.2
( function ( root , factory ) { if ( typeof exports == "object" ) { module . exports = factory ( ) } else { if ( typeof define == "function" && define . amd ) { define ( factory ) } else { root . Spinner = factory ( ) } } } ( this , function ( ) { var prefixes = [ "webkit" , "Moz" , "ms" , "O" ] , animations = { } , useCssAnimations ; function createEl ( tag , prop ) { var el = document . createElement ( tag || "div" ) , n ; for ( n in prop ) { el [ n ] = prop [ n ] } return el } function ins ( parent ) { for ( var i = 1 , n = arguments . length ; i < n ; i ++ ) { parent . appendChild ( arguments [ i ] ) } return parent } var sheet = ( function ( ) { var el = createEl ( "style" , { type : "text/css" } ) ; ins ( document . getElementsByTagName ( "head" ) [ 0 ] , el ) ; return el . sheet || el . styleSheet } ( ) ) ; function addAnimation ( alpha , trail , i , lines ) { var name = [ "opacity" , trail , ~ ~ ( alpha * 100 ) , i , lines ] . join ( "-" ) , start = 0.01 + i / lines * 100 , z = Math . max ( 1 - ( 1 - alpha ) / trail * ( 100 - start ) , alpha ) , prefix = useCssAnimations . substring ( 0 , useCssAnimations . indexOf ( "Animation" ) ) . toLowerCase ( ) , pre = prefix && "-" + prefix + "-" || "" ; if ( ! animations [ name ] ) { sheet . insertRule ( "@" + pre + "keyframes " + name + "{0%{opacity:" + z + "}" + start + "%{opacity:" + alpha + "}" + ( start + 0.01 ) + "%{opacity:1}" + ( start + trail ) % 100 + "%{opacity:" + alpha + "}100%{opacity:" + z + "}}" , sheet . cssRules . length ) ; animations [ name ] = 1 } return name } function vendor ( el , prop ) { var s = el . style , pp , i ; prop = prop . charAt ( 0 ) . toUpperCase ( ) + prop . slice ( 1 ) ; for ( i = 0 ; i < prefixes . length ; i ++ ) { pp = prefixes [ i ] + prop ; if ( s [ pp ] !== undefined ) { return pp } } if ( s [ prop ] !== undefined ) { return prop } } function css ( el , prop ) { for ( var n in prop ) { el . style [ vendor ( el , n ) || n ] = prop [ n ] } return el } function merge ( obj ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var def = arguments [ i ] ; for ( var n in def ) { if ( obj [ n ] === undefined ) { obj [ n ] = def [ n ] } } } return obj } function pos ( el ) { var o = { x : el . offsetLeft , y : el . offsetTop } ; while ( ( el = el . offsetParent ) ) { o . x += el . offsetLeft , o . y += el . offsetTop } return o } function getColor ( color , idx ) { return typeof color == "string" ? color : color [ idx % color . length ] } var defaults = { lines : 12 , length : 7 , width : 5 , radius : 10 , rotate : 0 , corners : 1 , color : "#000" , direction : 1 , speed : 1 , trail : 100 , opacity : 1 / 4 , fps : 20 , zIndex : "auto" , className : "spinner" , top : "auto" , left : "auto" , position : "relative" } ; function Spinner ( o ) { if ( typeof this == "undefined" ) { return new Spinner ( o ) } this . opts = merge ( o || { } , Spinner . defaults , defaults ) } Spinner . defaults = { } ; merge ( Spinner . prototype , { spin : function ( target ) { this . stop ( ) ; var self = this , o = self . opts , el = self . el = css ( createEl ( 0 , { className : o . className } ) , { position : o . position , width : 0 , zIndex : o . zIndex } ) , mid = o . radius + o . length + o . width , ep , tp ; if ( target ) { target . insertBefore ( el , target . firstChild || null ) ; tp = pos ( target ) ; ep = pos ( el ) ; css ( el , { left : ( o . left == "auto" ? tp . x - ep . x + ( target . offsetWidth >> 1 ) : parseInt ( o . left , 10 ) + mid ) + "px" , top : ( o . top == "auto" ? tp . y - ep . y + ( target . offsetHeight >> 1 ) : parseInt ( o . top , 10 ) + mid ) + "px" } ) } el . setAttribute ( "role" , "progressbar" ) ; self . lines ( el , self . opts ) ; if ( ! useCssAnimations ) { var i = 0 , start = ( o . lines - 1 ) * ( 1 - o . direction ) / 2 , alpha , fps = o . fps , f = fps / o . speed , ostep = ( 1 - o . opacity ) / ( f * o . trail / 100 ) , astep = f / o . lines ; ( function anim ( ) { i ++ ; for ( var j = 0 ; j < o . lines ; j ++ ) { alpha = Math . max ( 1 - ( i + ( o . lines - j ) * astep ) % f * ostep , o . opacity ) ; self . opacity ( el , j * o . direction + start , alpha , o ) } self . timeout = self . el && setTimeout ( anim , ~ ~ ( 1000 / fps ) ) } ) ( ) } return self } , stop : function ( ) { var el = this . el ; if ( el ) { clearTimeout ( this . timeout ) ; if ( el . parentNode ) { el . parentNode . removeChild ( el ) } this . el = undefined } return this } , lines : function ( el , o ) { var i = 0 , start = ( o . lines - 1 ) * ( 1 - o . direction ) / 2 , seg ; function fill ( color , shadow ) { return css ( createEl ( ) , { position : "absolute" , width : ( o . length + o . width ) + "px" , height : o . width + "px" , background : color , boxShadow : shadow , transformOrigin : "left" , transform : "rotate(" + ~ ~ ( 360 / o . lines * i + o . rotate ) + "deg) translate(" + o . radius + "px,0)" , borderRadius : ( o . corners * o . width >> 1 ) + "px" } ) } for ( ; i < o . lines ; i ++ ) { seg = css ( createEl ( ) , { position : "absolute" , top : 1 + ~ ( o . width / 2 ) + "px" , transform : o . hwaccel ? "translate3d(0,0,0)" : "" , opacity : o . opacity , animation : useCssAnimations && addAnimation ( o . opacity , o . trail , start + i * o . direction , o . lines ) + " " + 1 / o . speed + "s linear infinite" } ) ; if ( o . shadow ) { ins ( seg , css ( fill ( "rgba(0,0,0,.25)" , "0 0 4px rgba(0,0,0,.5)" ) , { top : 2 + "px" } ) ) } ins ( el , ins ( seg , fill ( getColor ( o . color , i ) , "0 0 1px rgba(0,0,0,.1)" ) ) ) } return el } , opacity : function ( el , i , val ) { if ( i < el . chil
( function ( e ) { if ( typeof exports == "object" ) { e ( require ( "jquery" ) , require ( "spin" ) ) } else if ( typeof define == "function" && define . amd ) { define ( [ "jquery" , "spin" ] , e ) } else { if ( ! window . Spinner ) throw new Error ( "Spin.js not present" ) ; e ( window . jQuery , window . Spinner ) } } ) ( function ( e , t ) { e . fn . spin = function ( n , r ) { return this . each ( function ( ) { var i = e ( this ) , s = i . data ( ) ; if ( s . spinner ) { s . spinner . stop ( ) ; delete s . spinner } if ( n !== false ) { n = e . extend ( { color : r || i . css ( "color" ) } , e . fn . spin . presets [ n ] || n ) ; s . spinner = ( new t ( n ) ) . spin ( this ) } } ) } ; e . fn . spin . presets = { tiny : { lines : 8 , length : 2 , width : 2 , radius : 3 } , small : { lines : 8 , length : 4 , width : 3 , radius : 5 } , large : { lines : 10 , length : 8 , width : 4 , radius : 8 } } } ) ;
// http://stackoverflow.com/a/21422049
( function ( e ) { e . fn . hasScrollBar = function ( ) { var e = { } , t = this . get ( 0 ) ; e . vertical = t . scrollHeight > t . clientHeight ? true : false ; e . horizontal = t . scrollWidth > t . clientWidth ? true : false ; return e } } ) ( jQuery ) ;
/ * *
* Antiscroll
* https : //github.com/LearnBoost/antiscroll
* /
( function ( $ ) { $ . fn . antiscroll = function ( options ) { return this . each ( function ( ) { if ( $ ( this ) . data ( "antiscroll" ) ) $ ( this ) . data ( "antiscroll" ) . destroy ( ) ; $ ( this ) . data ( "antiscroll" , new $ . Antiscroll ( this , options ) ) } ) } ; $ . Antiscroll = Antiscroll ; function Antiscroll ( el , opts ) { this . el = $ ( el ) ; this . options = opts || { } ; this . x = false !== this . options . x || this . options . forceHorizontal ; this . y = false !== this . options . y || this . options . forceVertical ; this . autoHide = false !== this . options . autoHide ; this . padding = undefined == this . options . padding ? 2 :
this . options . padding ; this . inner = this . el . find ( ".antiscroll-inner" ) ; this . inner . css ( { "width" : "+=" + ( this . y ? scrollbarSize ( ) : 0 ) , "height" : "+=" + ( this . x ? scrollbarSize ( ) : 0 ) } ) ; this . refresh ( ) } Antiscroll . prototype . refresh = function ( ) { var needHScroll = this . inner . get ( 0 ) . scrollWidth > this . el . width ( ) + ( this . y ? scrollbarSize ( ) : 0 ) , needVScroll = this . inner . get ( 0 ) . scrollHeight > this . el . height ( ) + ( this . x ? scrollbarSize ( ) : 0 ) ; if ( this . x ) if ( ! this . horizontal && needHScroll ) this . horizontal = new Scrollbar . Horizontal ( this ) ; else if ( this . horizontal &&
! needHScroll ) { this . horizontal . destroy ( ) ; this . horizontal = null } else if ( this . horizontal ) this . horizontal . update ( ) ; if ( this . y ) if ( ! this . vertical && needVScroll ) this . vertical = new Scrollbar . Vertical ( this ) ; else if ( this . vertical && ! needVScroll ) { this . vertical . destroy ( ) ; this . vertical = null } else if ( this . vertical ) this . vertical . update ( ) } ; Antiscroll . prototype . destroy = function ( ) { if ( this . horizontal ) { this . horizontal . destroy ( ) ; this . horizontal = null } if ( this . vertical ) { this . vertical . destroy ( ) ; this . vertical = null } return this } ;
Antiscroll . prototype . rebuild = function ( ) { this . destroy ( ) ; this . inner . attr ( "style" , "" ) ; Antiscroll . call ( this , this . el , this . options ) ; return this } ; function Scrollbar ( pane ) { this . pane = pane ; this . pane . el . append ( this . el ) ; this . innerEl = this . pane . inner . get ( 0 ) ; this . dragging = false ; this . enter = false ; this . shown = false ; this . pane . el . mouseenter ( $ . proxy ( this , "mouseenter" ) ) ; this . pane . el . mouseleave ( $ . proxy ( this , "mouseleave" ) ) ; this . el . mousedown ( $ . proxy ( this , "mousedown" ) ) ; this . innerPaneScrollListener = $ . proxy ( this , "scroll" ) ; this . pane . inner . scroll ( this . innerPaneScrollListener ) ;
this . innerPaneMouseWheelListener = $ . proxy ( this , "mousewheel" ) ; this . pane . inner . bind ( "mousewheel" , this . innerPaneMouseWheelListener ) ; var initialDisplay = this . pane . options . initialDisplay ; if ( initialDisplay !== false ) { this . show ( ) ; if ( this . pane . autoHide ) this . hiding = setTimeout ( $ . proxy ( this , "hide" ) , parseInt ( initialDisplay , 10 ) || 3E3 ) } } Scrollbar . prototype . destroy = function ( ) { this . el . remove ( ) ; this . pane . inner . unbind ( "scroll" , this . innerPaneScrollListener ) ; this . pane . inner . unbind ( "mousewheel" , this . innerPaneMouseWheelListener ) ;
return this } ; Scrollbar . prototype . mouseenter = function ( ) { this . enter = true ; this . show ( ) } ; Scrollbar . prototype . mouseleave = function ( ) { this . enter = false ; if ( ! this . dragging ) if ( this . pane . autoHide ) this . hide ( ) } ; Scrollbar . prototype . scroll = function ( ) { if ( ! this . shown ) { this . show ( ) ; if ( ! this . enter && ! this . dragging ) if ( this . pane . autoHide ) this . hiding = setTimeout ( $ . proxy ( this , "hide" ) , 1500 ) } this . update ( ) } ; Scrollbar . prototype . mousedown = function ( ev ) { ev . preventDefault ( ) ; this . dragging = true ; this . startPageY = ev . pageY - parseInt ( this . el . css ( "top" ) ,
10 ) ; this . startPageX = ev . pageX - parseInt ( this . el . css ( "left" ) , 10 ) ; this . el [ 0 ] . ownerDocument . onselectstart = function ( ) { return false } ; var pane = this . pane , move = $ . proxy ( this , "mousemove" ) , self = this ; $ ( this . el [ 0 ] . ownerDocument ) . mousemove ( move ) . mouseup ( function ( ) { self . dragging = false ; this . onselectstart = null ; $ ( this ) . unbind ( "mousemove" , move ) ; if ( ! self . enter ) self . hide ( ) } ) } ; Scrollbar . prototype . show = function ( duration ) { if ( ! this . shown && this . update ( ) ) { this . el . addClass ( "antiscroll-scrollbar-shown" ) ; if ( this . hiding ) { clearTimeout ( this . hiding ) ;
this . hiding = null } this . shown = true } } ; Scrollbar . prototype . hide = function ( ) { if ( this . pane . autoHide !== false && this . shown ) { this . el . removeClass ( "antiscroll-scrollbar-shown" ) ; this . shown = false } } ; Scrollbar . Horizontal = function ( pane ) { this . el = $ ( '<div class="antiscroll-scrollbar antiscroll-scrollbar-horizontal">' , pane . el ) ; Scrollbar . call ( this , pane ) } ; inherits ( Scrollbar . Horizontal , Scrollbar ) ; Scrollbar . Horizontal . prototype . update = function ( ) { var paneWidth = this . pane . el . width ( ) , trackWidth = paneWidth - this . pane . padding * 2 , innerEl =
this . pane . inner . get ( 0 ) ; this . el . css ( "width" , trackWidth * paneWidth / innerEl . scrollWidth ) . css ( "left" , trackWidth * innerEl . scrollLeft / innerEl . scrollWidth ) ; return paneWidth < innerEl . scrollWidth } ; Scrollbar . Horizontal . prototype . mousemove = function ( ev ) { var trackWidth = this . pane . el . width ( ) - this . pane . padding * 2 , pos = ev . pageX - this . startPageX , barWidth = this . el . width ( ) , innerEl = this . pane . inner . get ( 0 ) ; var y = Math . min ( Math . max ( pos , 0 ) , trackWidth - barWidth ) ; innerEl . scrollLeft = ( innerEl . scrollWidth - this . pane . el . width ( ) ) * y / ( trackWidth -
barWidth ) } ; Scrollbar . Horizontal . prototype . mousewheel = function ( ev , delta , x , y ) { if ( x < 0 && 0 == this . pane . inner . get ( 0 ) . scrollLeft || x > 0 && this . innerEl . scrollLeft + Math . ceil ( this . pane . el . width ( ) ) == this . innerEl . scrollWidth ) { ev . preventDefault ( ) ; return false } } ; Scrollbar . Vertical = function ( pane ) { this . el = $ ( '<div class="antiscroll-scrollbar antiscroll-scrollbar-vertical">' , pane . el ) ; Scrollbar . call ( this , pane ) } ; inherits ( Scrollbar . Vertical , Scrollbar ) ; Scrollbar . Vertical . prototype . update = function ( ) { var paneHeight = this . pane . el . height ( ) ,
trackHeight = paneHeight - this . pane . padding * 2 , innerEl = this . innerEl ; var scrollbarHeight = trackHeight * paneHeight / innerEl . scrollHeight ; scrollbarHeight = scrollbarHeight < 20 ? 20 : scrollbarHeight ; var topPos = trackHeight * innerEl . scrollTop / innerEl . scrollHeight ; if ( topPos + scrollbarHeight > trackHeight ) { var diff = topPos + scrollbarHeight - trackHeight ; topPos = topPos - diff - 3 } this . el . css ( "height" , scrollbarHeight ) . css ( "top" , topPos ) ; return paneHeight < innerEl . scrollHeight } ; Scrollbar . Vertical . prototype . mousemove = function ( ev ) { var paneHeight =
this . pane . el . height ( ) , trackHeight = paneHeight - this . pane . padding * 2 , pos = ev . pageY - this . startPageY , barHeight = this . el . height ( ) , innerEl = this . innerEl ; var y = Math . min ( Math . max ( pos , 0 ) , trackHeight - barHeight ) ; innerEl . scrollTop = ( innerEl . scrollHeight - paneHeight ) * y / ( trackHeight - barHeight ) } ; Scrollbar . Vertical . prototype . mousewheel = function ( ev , delta , x , y ) { if ( y > 0 && 0 == this . innerEl . scrollTop || y < 0 && this . innerEl . scrollTop + Math . ceil ( this . pane . el . height ( ) ) == this . innerEl . scrollHeight ) { ev . preventDefault ( ) ; return false } } ; function inherits ( ctorA ,
ctorB ) { function f ( ) { } f . prototype = ctorB . prototype ; ctorA . prototype = new f } var size ; function scrollbarSize ( ) { if ( size === undefined ) { var div = $ ( '<div class="antiscroll-inner" style="width:50px;height:50px;overflow-y:scroll;' + 'position:absolute;top:-200px;left:-200px;"><div style="height:100px;width:100%">' + "</div>" ) ; $ ( "body" ) . append ( div ) ; var w1 = $ ( div ) . innerWidth ( ) ; var w2 = $ ( "div" , div ) . innerWidth ( ) ; $ ( div ) . remove ( ) ; size = w1 - w2 } return size } } ) ( jQuery ) ;
/ * *
* jQuery Mousewheel
* ! Copyright ( c ) 2013 Brandon Aaron ( http : //brandonaaron.net)
* Licensed under the MIT License ( LICENSE . txt ) .
*
* Thanks to : http : //adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to : Mathias Bank ( http : //www.mathias-bank.de) for a scope bug fix.
* Thanks to : Seamus Leahy for adding deltaX and deltaY
*
* Version : 3.1 . 3
*
* Requires : 1.2 . 2 +
* /
( function ( factory ) { if ( typeof define === "function" && define . amd ) define ( [ "jquery" ] , factory ) ; else if ( typeof exports === "object" ) module . exports = factory ; else factory ( jQuery ) } ) ( function ( $ ) { var toFix = [ "wheel" , "mousewheel" , "DOMMouseScroll" , "MozMousePixelScroll" ] ; var toBind = "onwheel" in document || document . documentMode >= 9 ? [ "wheel" ] : [ "mousewheel" , "DomMouseScroll" , "MozMousePixelScroll" ] ; var lowestDelta , lowestDeltaXY ; if ( $ . event . fixHooks ) for ( var i = toFix . length ; i ; ) $ . event . fixHooks [ toFix [ -- i ] ] = $ . event . mouseHooks ; $ . event . special . mousewheel =
{ setup : function ( ) { if ( this . addEventListener ) for ( var i = toBind . length ; i ; ) this . addEventListener ( toBind [ -- i ] , handler , false ) ; else this . onmousewheel = handler } , teardown : function ( ) { if ( this . removeEventListener ) for ( var i = toBind . length ; i ; ) this . removeEventListener ( toBind [ -- i ] , handler , false ) ; else this . onmousewheel = null } } ; $ . fn . extend ( { mousewheel : function ( fn ) { return fn ? this . bind ( "mousewheel" , fn ) : this . trigger ( "mousewheel" ) } , unmousewheel : function ( fn ) { return this . unbind ( "mousewheel" , fn ) } } ) ; function handler ( event ) { var orgEvent =
event || window . event , args = [ ] . slice . call ( arguments , 1 ) , delta = 0 , deltaX = 0 , deltaY = 0 , absDelta = 0 , absDeltaXY = 0 , fn ; event = $ . event . fix ( orgEvent ) ; event . type = "mousewheel" ; if ( orgEvent . wheelDelta ) delta = orgEvent . wheelDelta ; if ( orgEvent . detail ) delta = orgEvent . detail * - 1 ; if ( orgEvent . deltaY ) { deltaY = orgEvent . deltaY * - 1 ; delta = deltaY } if ( orgEvent . deltaX ) { deltaX = orgEvent . deltaX ; delta = deltaX * - 1 } if ( orgEvent . wheelDeltaY !== undefined ) deltaY = orgEvent . wheelDeltaY ; if ( orgEvent . wheelDeltaX !== undefined ) deltaX = orgEvent . wheelDeltaX * - 1 ; absDelta =
Math . abs ( delta ) ; if ( ! lowestDelta || absDelta < lowestDelta ) lowestDelta = absDelta ; absDeltaXY = Math . max ( Math . abs ( deltaY ) , Math . abs ( deltaX ) ) ; if ( ! lowestDeltaXY || absDeltaXY < lowestDeltaXY ) lowestDeltaXY = absDeltaXY ; fn = delta > 0 ? "floor" : "ceil" ; delta = Math [ fn ] ( delta / lowestDelta ) ; deltaX = Math [ fn ] ( deltaX / lowestDeltaXY ) ; deltaY = Math [ fn ] ( deltaY / lowestDeltaXY ) ; args . unshift ( event , delta , deltaX , deltaY ) ; return ( $ . event . dispatch || $ . event . handle ) . apply ( this , args ) } } ) ;
/ * *
Delayed action
http : //stackoverflow.com/a/7150496
* * /
( function ( $ ) {
$ . fn . delayedAction = function ( options )
{
var settings = $ . extend (
{ } ,
{
delayedAction : function ( ) { } ,
cancelledAction : function ( ) { } ,
2018-04-17 21:25:26 +00:00
hoverTime : 1000
2016-08-18 20:39:31 +00:00
} ,
options ) ;
return this . each ( function ( ) {
var $this = $ ( this ) ;
2018-04-17 21:25:26 +00:00
$this . hover ( function ( ) {
2016-08-18 20:39:31 +00:00
$this . data ( 'timerId' ,
setTimeout ( function ( ) {
$this . data ( 'hover' , false ) ;
settings . delayedAction ( $this ) ;
} , settings . hoverTime ) ) ;
$this . data ( 'hover' , true ) ;
} ,
2018-04-17 21:25:26 +00:00
function ( ) {
if ( $this . data ( 'hover' ) ) {
2016-08-18 20:39:31 +00:00
clearTimeout ( $this . data ( 'timerId' ) ) ;
settings . cancelledAction ( $this ) ;
}
$this . data ( 'hover' , false ) ;
} ) ;
} ) ;
}
} ) ( jQuery ) ;
/ * *
Created : 20060120
Author : Steve Moitozo < god at zilla dot us > -- geekwisdom . com
License : MIT License ( see below )
Copyright ( c ) 2006 Steve Moitozo < god at zilla dot us >
Slightly modified for Peafowl
* /
function testPassword ( e ) { var t = 0 , n = "weak" , r = "" , i = 0 ; if ( e . length < 5 ) { t = t + 3 ; r = r + "3 points for length (" + e . length + ")\n" } else if ( e . length > 4 && e . length < 8 ) { t = t + 6 ; r = r + "6 points for length (" + e . length + ")\n" } else if ( e . length > 7 && e . length < 16 ) { t = t + 12 ; r = r + "12 points for length (" + e . length + ")\n" } else if ( e . length > 15 ) { t = t + 18 ; r = r + "18 point for length (" + e . length + ")\n" } if ( e . match ( /[a-z]/ ) ) { t = t + 1 ; r = r + "1 point for at least one lower case char\n" } if ( e . match ( /[A-Z]/ ) ) { t = t + 5 ; r = r + "5 points for at least one upper case char\n" } if ( e . match ( /\d+/ ) ) { t = t + 5 ; r = r + "5 points for at least one number\n" } if ( e . match ( /(.*[0-9].*[0-9].*[0-9])/ ) ) { t = t + 5 ; r = r + "5 points for at least three numbers\n" } if ( e . match ( /.[!,@,#,$,%,^,&,*,?,_,~]/ ) ) { t = t + 5 ; r = r + "5 points for at least one special char\n" } if ( e . match ( /(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/ ) ) { t = t + 5 ; r = r + "5 points for at least two special chars\n" } if ( e . match ( /([a-z].*[A-Z])|([A-Z].*[a-z])/ ) ) { t = t + 2 ; r = r + "2 combo points for upper and lower letters\n" } if ( e . match ( /([a-zA-Z])/ ) && e . match ( /([0-9])/ ) ) { t = t + 2 ; r = r + "2 combo points for letters and numbers\n" } if ( e . match ( /([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/ ) ) { t = t + 2 ; r = r + "2 combo points for letters, numbers and special chars\n" } if ( e . length == 0 ) { t = 0 } if ( t < 16 ) { n = "very weak" } else if ( t > 15 && t < 25 ) { n = "weak" } else if ( t > 24 && t < 35 ) { n = "average" } else if ( t > 34 && t < 45 ) { n = "strong" } else { n = "stronger" } i = Math . round ( Math . min ( 100 , 100 * t / 45 ) ) / 100 ; return { score : t , ratio : i , percent : i * 100 + "%" , verdict : n , log : r } }
// SparkMD5
( function ( factory ) { if ( typeof exports === "object" ) { module . exports = factory ( ) } else if ( typeof define === "function" && define . amd ) { define ( factory ) } else { var glob ; try { glob = window } catch ( e ) { glob = self } glob . SparkMD5 = factory ( ) } } ) ( function ( undefined ) { "use strict" ; var add32 = function ( a , b ) { return a + b & 4294967295 } , hex _chr = [ "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "a" , "b" , "c" , "d" , "e" , "f" ] ; function cmn ( q , a , b , x , s , t ) { a = add32 ( add32 ( a , q ) , add32 ( x , t ) ) ; return add32 ( a << s | a >>> 32 - s , b ) } function ff ( a , b , c , d , x , s , t ) { return cmn ( b & c | ~ b & d , a , b , x , s , t ) } function gg ( a , b , c , d , x , s , t ) { return cmn ( b & d | c & ~ d , a , b , x , s , t ) } function hh ( a , b , c , d , x , s , t ) { return cmn ( b ^ c ^ d , a , b , x , s , t ) } function ii ( a , b , c , d , x , s , t ) { return cmn ( c ^ ( b | ~ d ) , a , b , x , s , t ) } function md5cycle ( x , k ) { var a = x [ 0 ] , b = x [ 1 ] , c = x [ 2 ] , d = x [ 3 ] ; a = ff ( a , b , c , d , k [ 0 ] , 7 , - 680876936 ) ; d = ff ( d , a , b , c , k [ 1 ] , 12 , - 389564586 ) ; c = ff ( c , d , a , b , k [ 2 ] , 17 , 606105819 ) ; b = ff ( b , c , d , a , k [ 3 ] , 22 , - 1044525330 ) ; a = ff ( a , b , c , d , k [ 4 ] , 7 , - 176418897 ) ; d = ff ( d , a , b , c , k [ 5 ] , 12 , 1200080426 ) ; c = ff ( c , d , a , b , k [ 6 ] , 17 , - 1473231341 ) ; b = ff ( b , c , d , a , k [ 7 ] , 22 , - 45705983 ) ; a = ff ( a , b , c , d , k [ 8 ] , 7 , 1770035416 ) ; d = ff ( d , a , b , c , k [ 9 ] , 12 , - 1958414417 ) ; c = ff ( c , d , a , b , k [ 10 ] , 17 , - 42063 ) ; b = ff ( b , c , d , a , k [ 11 ] , 22 , - 1990404162 ) ; a = ff ( a , b , c , d , k [ 12 ] , 7 , 1804603682 ) ; d = ff ( d , a , b , c , k [ 13 ] , 12 , - 40341101 ) ; c = ff ( c , d , a , b , k [ 14 ] , 17 , - 1502002290 ) ; b = ff ( b , c , d , a , k [ 15 ] , 22 , 1236535329 ) ; a = gg ( a , b , c , d , k [ 1 ] , 5 , - 165796510 ) ; d = gg ( d , a , b , c , k [ 6 ] , 9 , - 1069501632 ) ; c = gg ( c , d , a , b , k [ 11 ] , 14 , 643717713 ) ; b = gg ( b , c , d , a , k [ 0 ] , 20 , - 373897302 ) ; a = gg ( a , b , c , d , k [ 5 ] , 5 , - 701558691 ) ; d = gg ( d , a , b , c , k [ 10 ] , 9 , 38016083 ) ; c = gg ( c , d , a , b , k [ 15 ] , 14 , - 660478335 ) ; b = gg ( b , c , d , a , k [ 4 ] , 20 , - 405537848 ) ; a = gg ( a , b , c , d , k [ 9 ] , 5 , 568446438 ) ; d = gg ( d , a , b , c , k [ 14 ] , 9 , - 1019803690 ) ; c = gg ( c , d , a , b , k [ 3 ] , 14 , - 187363961 ) ; b = gg ( b , c , d , a , k [ 8 ] , 20 , 1163531501 ) ; a = gg ( a , b , c , d , k [ 13 ] , 5 , - 1444681467 ) ; d = gg ( d , a , b , c , k [ 2 ] , 9 , - 51403784 ) ; c = gg ( c , d , a , b , k [ 7 ] , 14 , 1735328473 ) ; b = gg ( b , c , d , a , k [ 12 ] , 20 , - 1926607734 ) ; a = hh ( a , b , c , d , k [ 5 ] , 4 , - 378558 ) ; d = hh ( d , a , b , c , k [ 8 ] , 11 , - 2022574463 ) ; c = hh ( c , d , a , b , k [ 11 ] , 16 , 1839030562 ) ; b = hh ( b , c , d , a , k [ 14 ] , 23 , - 35309556 ) ; a = hh ( a , b , c , d , k [ 1 ] , 4 , - 1530992060 ) ; d = hh ( d , a , b , c , k [ 4 ] , 11 , 1272893353 ) ; c = hh ( c , d , a , b , k [ 7 ] , 16 , - 155497632 ) ; b = hh ( b , c , d , a , k [ 10 ] , 23 , - 1094730640 ) ; a = hh ( a , b , c , d , k [ 13 ] , 4 , 681279174 ) ; d = hh ( d , a , b , c , k [ 0 ] , 11 , - 358537222 ) ; c = hh ( c , d , a , b , k [ 3 ] , 16 , - 722521979 ) ; b = hh ( b , c , d , a , k [ 6 ] , 23 , 76029189 ) ; a = hh ( a , b , c , d , k [ 9 ] , 4 , - 640364487 ) ; d = hh ( d , a , b , c , k [ 12 ] , 11 , - 421815835 ) ; c = hh ( c , d , a , b , k [ 15 ] , 16 , 530742520 ) ; b = hh ( b , c , d , a , k [ 2 ] , 23 , - 995338651 ) ; a = ii ( a , b , c , d , k [ 0 ] , 6 , - 198630844 ) ; d = ii ( d , a , b , c , k [ 7 ] , 10 , 1126891415 ) ; c = ii ( c , d , a , b , k [ 14 ] , 15 , - 1416354905 ) ; b = ii ( b , c , d , a , k [ 5 ] , 21 , - 57434055 ) ; a = ii ( a , b , c , d , k [ 12 ] , 6 , 1700485571 ) ; d = ii ( d , a , b , c , k [ 3 ] , 10 , - 1894986606 ) ; c = ii ( c , d , a , b , k [ 10 ] , 15 , - 1051523 ) ; b = ii ( b , c , d , a , k [ 1 ] , 21 , - 2054922799 ) ; a = ii ( a , b , c , d , k [ 8 ] , 6 , 1873313359 ) ; d = ii ( d , a , b , c , k [ 15 ] , 10 , - 30611744 ) ; c = ii ( c , d , a , b , k [ 6 ] , 15 , - 1560198380 ) ; b = ii ( b , c , d , a , k [ 13 ] , 21 , 1309151649 ) ; a = ii ( a , b , c , d , k [ 4 ] , 6 , - 145523070 ) ; d = ii ( d , a , b , c , k [ 11 ] , 10 , - 1120210379 ) ; c = ii ( c , d , a , b , k [ 2 ] , 15 , 718787259 ) ; b = ii ( b , c , d , a , k [ 9 ] , 21 , - 343485551 ) ; x [ 0 ] = add32 ( a , x [ 0 ] ) ; x [ 1 ] = add32 ( b , x [ 1 ] ) ; x [ 2 ] = add32 ( c , x [ 2 ] ) ; x [ 3 ] = add32 ( d , x [ 3 ] ) } function md5blk ( s ) { var md5blks = [ ] , i ; for ( i = 0 ; i < 64 ; i += 4 ) { md5blks [ i >> 2 ] = s . charCodeAt ( i ) + ( s . charCodeAt ( i + 1 ) << 8 ) + ( s . charCodeAt ( i + 2 ) << 16 ) + ( s . charCodeAt ( i + 3 ) << 24 ) } return md5blks } function md5blk _array ( a ) { var md5blks = [ ] , i ; for ( i = 0 ; i < 64 ; i += 4 ) { md5blks [ i >> 2 ] = a [ i ] + ( a [ i + 1 ] << 8 ) + ( a [ i + 2 ] << 16 ) + ( a [ i + 3 ] << 24 ) } return md5blks } function md51 ( s ) { var n = s . length , state = [ 1732584193 , - 271733879 , - 1732584194 , 271733878 ] , i , length , tail , tmp , lo , hi ; for ( i = 64 ; i <= n ; i += 64 ) { md5cycle ( state , md5blk ( s . substring ( i - 64 , i ) ) ) } s = s . substring ( i - 64 ) ; length = s . length ; tail = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; for ( i = 0 ; i < length ; i += 1 ) { tail [ i >> 2 ] |= s . charCodeAt ( i ) << ( i % 4 << 3 ) } tail [ i >> 2 ] |= 128 << ( i % 4 << 3 ) ; if ( i > 55 ) { md5cycle ( state , tail ) ; for ( i = 0 ; i < 16 ; i += 1 ) { tail [ i ] = 0 } } tmp = n * 8 ; tmp = tmp . toString ( 16 ) . match ( /(.*?)(.{0,8})$/ ) ; lo = parseInt ( tmp [ 2 ] , 16 ) ; hi = parseInt ( tmp [ 1 ] , 16 ) || 0 ; tail [ 14 ] = lo ; tail [ 15 ] = hi ; md5cycle ( state , tail ) ; return state } function md51 _array ( a ) { var n = a . length , state = [ 1732584193 , - 271733879 , - 1732584194 , 271733878 ] , i , length , tail , tmp , lo , hi ; for ( i = 64 ; i <= n ; i += 64 ) { md5cycle ( state , md5blk _array ( a . subarray ( i - 64 , i ) ) ) } a = i - 64 < n ? a . subarray ( i - 64 ) : new Uint8Array ( 0 ) ; length = a . length ; tail = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ; for ( i = 0 ; i < length ; i += 1 ) { tail [ i >
/ * !
* clipboard . js v1 . 5.8
* https : //zenorocha.github.io/clipboard.js
*
* Licensed MIT © Zeno Rocha
* /
2018-04-17 21:25:26 +00:00
! function ( t ) { if ( "object" == typeof exports && "undefined" != typeof module ) module . exports = t ( ) ; else if ( "function" == typeof define && define . amd ) define ( [ ] , t ) ; else { var e ; e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this , e . Clipboard = t ( ) } } ( function ( ) { var t , e , n ; return function t ( e , n , r ) { function o ( a , s ) { if ( ! n [ a ] ) { if ( ! e [ a ] ) { var c = "function" == typeof require && require ; if ( ! s && c ) return c ( a , ! 0 ) ; if ( i ) return i ( a , ! 0 ) ; var u = new Error ( "Cannot find module '" + a + "'" ) ; throw u . code = "MODULE_NOT_FOUND" , u } var l = n [ a ] = { exports : { } } ; e [ a ] [ 0 ] . call ( l . exports , function ( t ) { var n = e [ a ] [ 1 ] [ t ] ; return o ( n ? n : t ) } , l , l . exports , t , e , n , r ) } return n [ a ] . exports } for ( var i = "function" == typeof require && require , a = 0 ; a < r . length ; a ++ ) o ( r [ a ] ) ; return o } ( { 1 : [ function ( t , e , n ) { var r = t ( "matches-selector" ) ; e . exports = function ( t , e , n ) { for ( var o = n ? t : t . parentNode ; o && o !== document ; ) { if ( r ( o , e ) ) return o ; o = o . parentNode } } } , { "matches-selector" : 5 } ] , 2 : [ function ( t , e , n ) { function r ( t , e , n , r , i ) { var a = o . apply ( this , arguments ) ; return t . addEventListener ( n , a , i ) , { destroy : function ( ) { t . removeEventListener ( n , a , i ) } } } function o ( t , e , n , r ) { return function ( n ) { n . delegateTarget = i ( n . target , e , ! 0 ) , n . delegateTarget && r . call ( t , n ) } } var i = t ( "closest" ) ; e . exports = r } , { closest : 1 } ] , 3 : [ function ( t , e , n ) { n . node = function ( t ) { return void 0 !== t && t instanceof HTMLElement && 1 === t . nodeType } , n . nodeList = function ( t ) { var e = Object . prototype . toString . call ( t ) ; return void 0 !== t && ( "[object NodeList]" === e || "[object HTMLCollection]" === e ) && "length" in t && ( 0 === t . length || n . node ( t [ 0 ] ) ) } , n . string = function ( t ) { return "string" == typeof t || t instanceof String } , n . fn = function ( t ) { var e = Object . prototype . toString . call ( t ) ; return "[object Function]" === e } } , { } ] , 4 : [ function ( t , e , n ) { function r ( t , e , n ) { if ( ! t && ! e && ! n ) throw new Error ( "Missing required arguments" ) ; if ( ! s . string ( e ) ) throw new TypeError ( "Second argument must be a String" ) ; if ( ! s . fn ( n ) ) throw new TypeError ( "Third argument must be a Function" ) ; if ( s . node ( t ) ) return o ( t , e , n ) ; if ( s . nodeList ( t ) ) return i ( t , e , n ) ; if ( s . string ( t ) ) return a ( t , e , n ) ; throw new TypeError ( "First argument must be a String, HTMLElement, HTMLCollection, or NodeList" ) } function o ( t , e , n ) { return t . addEventListener ( e , n ) , { destroy : function ( ) { t . removeEventListener ( e , n ) } } } function i ( t , e , n ) { return Array . prototype . forEach . call ( t , function ( t ) { t . addEventListener ( e , n ) } ) , { destroy : function ( ) { Array . prototype . forEach . call ( t , function ( t ) { t . removeEventListener ( e , n ) } ) } } } function a ( t , e , n ) { return c ( document . body , t , e , n ) } var s = t ( "./is" ) , c = t ( "delegate" ) ; e . exports = r } , { "./is" : 3 , delegate : 2 } ] , 5 : [ function ( t , e , n ) { function r ( t , e ) { if ( i ) return i . call ( t , e ) ; for ( var n = t . parentNode . querySelectorAll ( e ) , r = 0 ; r < n . length ; ++ r ) if ( n [ r ] == t ) return ! 0 ; return ! 1 } var o = Element . prototype , i = o . matchesSelector || o . webkitMatchesSelector || o . mozMatchesSelector || o . msMatchesSelector || o . oMatchesSelector ; e . exports = r } , { } ] , 6 : [ function ( t , e , n ) { function r ( t ) { var e ; if ( "INPUT" === t . nodeName || "TEXTAREA" === t . nodeName ) t . focus ( ) , t . setSelectionRange ( 0 , t . value . length ) , e = t . value ; else { t . hasAttribute ( "contenteditable" ) && t . focus ( ) ; var n = window . getSelection ( ) , r = document . createRange ( ) ; r . selectNodeContents ( t ) , n . removeAllRanges ( ) , n . addRange ( r ) , e = n . toString ( ) } return e } e . exports = r } , { } ] , 7 : [ function ( t , e , n ) { function r ( ) { } r . prototype = { on : function ( t , e , n ) { var r = this . e || ( this . e = { } ) ; return ( r [ t ] || ( r [ t ] = [ ] ) ) . push ( { fn : e , ctx : n } ) , this } , once : function ( t , e , n ) { function r ( ) { o . off ( t , r ) , e . apply ( n , arguments ) } var o = this ; return r . _ = e , this . on ( t , r , n ) } , emit : function ( t ) { var e = [ ] . slice . call ( arguments , 1 ) , n = ( ( this . e || ( this . e = { } ) ) [ t ] || [ ] ) . slice ( ) , r = 0 , o = n . length ; for ( r ; o > r ; r ++ ) n [ r ] . fn . apply ( n [ r ] . ctx , e ) ; return this } , off : function ( t , e ) { var n = this . e || ( this . e = { } ) , r = n [ t ] , o = [ ] ; if ( r && e ) for ( var i = 0 , a = r . length ; a > i ; i ++ ) r [ i ] . fn !== e && r [ i ] . fn . _ !== e && o . push ( r [ i ] ) ; return o . length ? n [ t ] = o : delete n [ t ] , this } } , e . exports = r } , { } ] , 8 : [ function ( t , e , n ) { "use strict" ; function r ( t ) { return t && t . _ _esModule ? t : { "default" : t } } function o ( t , e ) { if ( ! ( t instanceof e ) ) throw new TypeError ( "Cannot call a class as a function" ) } n . _ _esModule = ! 0 ; var i = function ( ) { function t ( t , e ) { for ( var n = 0 ; n < e . length ; n ++ ) { var r = e [ n ] ; r . enumerable = r . enumerable || ! 1 , r . configurable = ! 0 , "value" in r && ( r . writable = ! 0 ) ,