Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wesleyhales/slidfast-1
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyhales committed May 26, 2012
2 parents 1a879c4 + 59329f4 commit a091b7f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 53 deletions.
2 changes: 1 addition & 1 deletion example/workers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<div id="home-page" class="page">
<h1>Home Page</h1>
<table id="log" style="">
<table id="log" style="border:1px solid black">
<thead>
<tr>
<td>Data</td>
Expand Down
82 changes: 36 additions & 46 deletions slidfast.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@

defaultPageID = null,

focusPage = null,

touchEnabled = false,

singlePageModel = false,

focusPage = null,

optimizeNetwork = false,

geo = {on : true, track : false},

orientationNav = true,
orientationNav = false,

workers = {script: null, threads: null, mycallback: null, obj: null},

isReady = false,

flipped = false;
flipped = false,

hashNS = "";

slidfast.core = slidfast.prototype = {
constructor: slidfast,
Expand All @@ -52,22 +54,22 @@

try {
if (options) {
//setup all the options being passed in in the init
defaultPageID = options.defaultPageID;
hashNS = options.hahsNS != null ? options.hashNS : "#sf-";
touchEnabled = options.touchEnabled;
singlePageModel = options.singlePageModel;
optimizeNetwork = options.optimizeNetwork;
geo = options.geo;
orientationNav = options.orientationNav;
workers = options.workers;

geo = options.geo != null ? options.geo : null;
workers = options.workers != null ? options.workers : null;
}
} catch(e) {
alert('Problem with startup options. You must define the page ID at a min. \n Error:' + e)
alert('Problem with init. Check your options: ' + e)
}

slidfast.core.hideURLBar();
//hash change
slidfast.core.locationChange();

//depends on proper DOM structure with defaultPageID
if (touchEnabled) {
new slidfast.ui.Touch(getElement(defaultPageID));
}
Expand All @@ -81,19 +83,22 @@
}
}

if (geo && geo.on == true) {
slidfast.location.init(geo);
}

if (orientationNav) {
slidfast.orientation.init();
}

//standalone without DOM structure
if (geo && geo.on == true) {
slidfast.location.init(geo);
}

if (workers && workers.script != null) {
slidfast.worker.init(workers);
}


slidfast.core.hideURLBar();
//hash change
slidfast.core.locationChange();
},

hideURLBar: function() {
Expand All @@ -105,7 +110,7 @@

window.addEventListener('load', function(e) {
isReady = true;
slidfast.core.start(defaultPageID, touchEnabled);
slidfast.core.start();
}, false);

window.addEventListener('hashchange', function(e) {
Expand All @@ -116,20 +121,18 @@

},

locationChange: function() {
if (location.hash === "#" + defaultPageID || location.hash == '') {
//slidfast.ui.slideTo(defaultPageID);
} else {

locationChange: function(id) {
var targetId = location.hash;
if(id){
location.hash = hashNS + id;
}else if(targetId){
try {
//todo - give the hash a safe namespace
targetId = location.hash;
//slidfast.ui.slideTo(targetId.replace('#sf-', ''));
console.log(targetId);
//todo implement for backbutton
// slidfast.ui.slideTo(targetId.replace(hashNS, ''));
} catch(e) {
console.log(e);
//alert(e)
}

}
},

Expand Down Expand Up @@ -326,7 +329,7 @@
try {
classes = id.className.split(' ');
} catch(e) {
console.log('problem with classname on .page: ' + id)
console.log('problem with classname on .page: ' + id.id)
}

//2.)decide if the incoming page is assigned to right or left
Expand All @@ -337,9 +340,8 @@
var front = getElement('front');
if (front) {
var frontNodes = front.getElementsByTagName('*');
var i;
for (i = 0; i < frontNodes.length; i += 1) {
if (id == frontNodes[i].id && flipped) {
for (var i = 0; i < frontNodes.length; i += 1) {
if (id.id == frontNodes[i].id && flipped) {
slidfast.ui.flip();
}
}
Expand All @@ -359,7 +361,8 @@
focusPage.className = 'page transition stage-center';

//6. make this transition bookmarkable
location.hash = '#sf-' + focusPage.id;
//console.log(focusPage.id);
slidfast.core.locationChange(focusPage.id);

if (touchEnabled) {
new slidfast.ui.Touch(focusPage);
Expand Down Expand Up @@ -506,6 +509,7 @@
};
track.ontouchend = function(event) {
pageMove(event);
//todo - this is a basic example, needs same code as orientationNav
if (slideDirection == 'left') {
slidfast.ui.slideTo('products-page');
} else if (slideDirection == 'right') {
Expand Down Expand Up @@ -979,20 +983,6 @@
} catch (e) {
return false;
}
},

supports_blobs : function() {
try {
if ('WebKitBlobBuilder' in window && window['WebKitBlobBuilder'] !== null) {
window.BlobBuilder = WebKitBlobBuilder;
return true;
} else if ('MozBlobBuilder' in window && window['MozBlobBuilder'] !== null) {
window.BlobBuilder = MozBlobBuilder;
return true;
}
} catch (e) {
return false;
}
}

};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
describe("Player", function() {
describe("slidfast", function() {

var test;
var defaultPageID = 'home-page'

beforeEach(function() {
test = "test";
});
slidfast({
defaultPageID:defaultPageID
});
});

it("should be able to play a Song", function() {
expect(test).toEqual("test");
it("should perform basic init", function() {
expect(slidfast).toBeDefined();
});

/* describe("when song has been paused", function() {
Expand Down

0 comments on commit a091b7f

Please sign in to comment.