Skip to content

Commit

Permalink
Update JS_3
Browse files Browse the repository at this point in the history
  • Loading branch information
gianlucagiglio committed Apr 27, 2013
1 parent 686b776 commit cfd3e98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
15 changes: 10 additions & 5 deletions js/plugin/zoomLight.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
//---
function openLayer (target){
console.log ( "ZoomLight: OpenLayer called!" );
var tmpTarget = typeof(target) !== undefined && ( typeof(target) === "string" || typeof(target) === "object" ) ? target : self.options.$openLayer;
var tmpTarget = test ( target, self.options.$openLayer );
handler ( tmpTarget, "click", function(){
self.options.$body.addClass(self.options.zoomOpenClass);
//Desktop mode
Expand All @@ -63,19 +63,24 @@
//---
function closeLayer (target){
console.log ( "ZoomLight: CloseLayer called!" );
var tmpTarget = typeof(target) !== undefined && ( typeof(target) === "string" || typeof(target) === "object" ) ? target : self.options.$closeLayer;
var tmpTarget = test ( target, self.options.$closeLayer );
handler ( tmpTarget, "click", function(){
self.options.$body.removeClass(self.options.zoomOpenClass);
destroy();
});
}

//---
function test ( target, def ){
return typeof(target) !== undefined && ( typeof(target) === "string" || typeof(target) === "object" ) ? target : def;
}

//---
function handler (target, action, fallback){
console.groupCollapsed ( "ZoomLight: Handler called!" );
console.log ( "target", target );
console.log ( "target %c" + action, "font-weight:bold; color: red;" );
console.log ( "target", fallback );
console.log ( "target: ", target );
console.log ( "action: %c" + action, "font-weight:bold; color: red;" );
console.log ( "fallback:", fallback );
console.groupEnd();
if ( typeof(target) === "string" ){
$(target).bind(action, fallback);
Expand Down
10 changes: 7 additions & 3 deletions js/scope/scope.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ $(function() {

//---
var options = {
$openLayer : ['#mainImage img', "#mainImage button"]
/*$openLayer : ['#mainImage img', "#mainImage button"]*/
};
//---
pool ( $("body"), "zoomLight", options );
//---
callApi ( "zoomLight", "openLayer", "#mainImage button" );
//Example button enabled open layer
//callApi ( "zoomLight", "openLayer", "#mainImage button" );
//Example delayed button enabled open layer
/*setTimeout ( function (){
callApi ( "zoomLight", "openLayer", "#mainImage button" );
}, 10000);*/

}catch (e){
//console.error(e);
Expand Down

0 comments on commit cfd3e98

Please sign in to comment.