Skip to content

Commit 4f4ee6a

Browse files
author
Andrew Mahon (Type/Code)
committed
Merging slated/typecode-js into origin/typecode-js/develop
1 parent 0ec49ca commit 4f4ee6a

File tree

8 files changed

+273
-219
lines changed

8 files changed

+273
-219
lines changed

lib/merlin/tc.merlin.data.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ typecode-js v 0.1
5858
for(i in fields){
5959
if(me.internal.current_step.fields[fields[i]] && internal.data[fields[i]]){
6060
if(me.internal.current_step.fields[fields[i]].component.get_val() != this.get_val(fields[i])){
61-
console.log(me.internal.current_step.fields[fields[i]].component.get_val());
62-
console.log(this.get_val(fields[i]));
63-
6461
me.internal.current_step.fields[fields[i]].component.set_val(this.get_val(fields[i]),true);
6562
}
6663
}
@@ -73,8 +70,6 @@ typecode-js v 0.1
7370
continue;
7471
}
7572
if(me.internal.current_step.fields[i].component.get_val() != this.get_val(i)){
76-
console.log(me.internal.current_step.fields[i].component.get_val());
77-
console.log(this.get_val(i));
7873
me.internal.current_step.fields[i].component.set_val(this.get_val(i),true);
7974
}
8075
}
@@ -85,11 +80,16 @@ typecode-js v 0.1
8580

8681
this.collect_fields = function(me, fields){
8782

88-
var i, temp_name;
83+
var i, temp_name, changed;
84+
85+
changed =[];
8986

9087
if(fields){
9188
for(i in fields){
9289
if(me.internal.current_step.fields[fields[i]]){
90+
if(me.internal.current_step.fields[fields[i]].component.get_val() != internal.base_data[i] && i != 'csrfmiddlewaretoken'){
91+
changed.push(i);
92+
}
9393
this.set_val(fields[i], me.internal.current_step.fields[fields[i]].component.get_val());
9494
}
9595
}
@@ -99,11 +99,16 @@ typecode-js v 0.1
9999
if(!me.internal.current_step.fields[i].component){
100100
continue;
101101
}
102+
if(me.internal.current_step.fields[i].component.get_val() != internal.base_data[i] && i != 'csrfmiddlewaretoken'){
103+
changed.push(i);
104+
}
102105
this.set_val(i, me.internal.current_step.fields[i].component.get_val());
103106
}
104107
}
105108
}
106109

110+
return changed;
111+
107112
};
108113

109114
this.get_uri = function(){
@@ -157,6 +162,10 @@ typecode-js v 0.1
157162
success:function(d,ts,xhr){
158163
internal.base_data = $.extend(internal.base_data,cleaned_data);
159164
callback(d);
165+
},
166+
error: function(){
167+
d = false;
168+
callback(d);
160169
}
161170
});
162171

lib/tc.browser_detection.js

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typecode-js v 0.1
2424

2525
o = $.extend({
2626
addClassToBody:true,
27-
orientationListen:true,
27+
orientationListen:false,
2828
detectWebApp:true
2929
}, options);
3030

@@ -33,28 +33,91 @@ typecode-js v 0.1
3333
};
3434

3535
function init(){
36-
if (navigator.userAgent.match(/iPad/i) != null) {
36+
var userAgent = navigator.userAgent;
37+
var appVersion = navigator.appVersion;
38+
var browser = $.browser;
39+
40+
// check if browser is webkit...
41+
if (browser.webkit) {
3742
if(o.addClassToBody){
38-
elements.body.addClass('browser-ipad');
43+
elements.body.addClass('browser-webkit');
3944
};
40-
if(o.orientationListen){
41-
listenToOrientationChange();
42-
};
43-
if(o.detectWebApp){
44-
if (window.navigator.standalone) { elements.body.addClass('ios-webapp') }
45+
46+
// check if it's chrome, safari, or an iOS browser
47+
if (userAgent.match(/iPad/i) != null) {
48+
if(o.addClassToBody){
49+
elements.body.addClass('browser-ipad os-ios');
50+
};
51+
if(o.orientationListen){
52+
listenToOrientationChange();
53+
};
54+
if(o.detectWebApp){
55+
if (window.navigator.standalone) { elements.body.addClass('ios-webapp') }
56+
}
57+
} else if(userAgent.match(/iPhone/i) || userAgent.match(/iPod/i)) {
58+
if(o.addClassToBody){
59+
elements.body.addClass('browser-iphone os-ios');
60+
};
61+
if(o.orientationListen){
62+
listenToOrientationChange();
63+
};
64+
if(o.detectWebApp){
65+
if (window.navigator.standalone) { elements.body.addClass('ios-webapp') }
66+
}
67+
} else if(userAgent.match(/Chrome/i)) {
68+
if(o.addClassToBody){
69+
elements.body.addClass('browser-chrome');
70+
};
71+
} else if(userAgent.match(/Safari/i)) {
72+
if(o.addClassToBody){
73+
elements.body.addClass('browser-safari');
74+
};
75+
}
76+
77+
// ...if browser is NOT webkit, run through the other browsers
78+
} else {
79+
if (browser.msie) {
80+
if(o.addClassToBody){
81+
elements.body.addClass('browser-ie');
82+
};
83+
} else if (browser.mozilla) {
84+
if(o.addClassToBody){
85+
elements.body.addClass('browser-firefox');
86+
};
87+
} else if (browser.opera) {
88+
if(o.addClassToBody){
89+
elements.body.addClass('browser-opera');
90+
};
4591
}
46-
} else if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
92+
};
93+
94+
95+
// now, detect operating systems
96+
if (appVersion.indexOf("Mac")!=-1) {
4797
if(o.addClassToBody){
48-
elements.body.addClass('browser-iphone');
98+
elements.body.addClass('os-mac');
4999
};
50-
if(o.orientationListen){
51-
listenToOrientationChange();
100+
} else if (appVersion.indexOf("Win")!=-1) {
101+
if(o.addClassToBody){
102+
elements.body.addClass('os-win');
52103
};
53-
if(o.detectWebApp){
54-
if (window.navigator.standalone) { elements.body.addClass('ios-webapp') }
55-
}
56-
}
57-
}
104+
} else if (appVersion.indexOf("X11")!=-1) {
105+
if(o.addClassToBody){
106+
elements.body.addClass('os-unix');
107+
};
108+
} else if (appVersion.indexOf("Linux")!=-1) {
109+
if(o.addClassToBody){
110+
elements.body.addClass('os-linux');
111+
};
112+
} else {
113+
if(o.addClassToBody){
114+
elements.body.addClass('os-unknown');
115+
};
116+
};
117+
118+
};
119+
120+
58121

59122
function listenToOrientationChange() {
60123

lib/tc.flippanel-OLD.js

Lines changed: 0 additions & 89 deletions
This file was deleted.

lib/tc.flippanel.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ typecode-js v 0.1
2323
as a direct child of both .front and .back, there must be a div with class .inner
2424
*/
2525
function flipPanel(eleContainer) {
26+
2627
// variables
2728
var flipContainer, frontBox, frontInner, backBox, backInner,
28-
frontTrigger, backTrigger, innerOuterDiff, speed, slideDelay;
29+
frontTrigger, backTrigger, innerOuterDiff, speed, slideDelay, webkitPerspective;
30+
31+
speed = 300; // speed of height change when flipping
32+
slideDelay = 200; // delay after flip starts before changing height
2933

34+
applyWebkitCSSinJS = true;
35+
webkitPerspective = 600;
36+
37+
3038
flipContainer = $(eleContainer);
3139
frontBox = flipContainer.children('.front');
3240
frontInner = frontBox.children('.inner');
@@ -36,43 +44,86 @@ function flipPanel(eleContainer) {
3644
backTrigger = flipContainer.find('.back-trigger');
3745

3846
innerOuterDiff = frontBox.height() - frontInner.height();
39-
40-
speed = 300;
41-
slideDelay = 200;
4247

48+
49+
50+
4351
// events
4452
frontTrigger.click(function(){
4553
frontBox.show();
54+
55+
if(applyWebkitCSSinJS) {
56+
flipContainer.css('-webkit-perspective', webkitPerspective);
57+
frontBox.css('-webkit-transform-style','preserve-3d');
58+
backBox.css('-webkit-transform-style','preserve-3d');
59+
};
60+
61+
backBox.find('.btn-edu').css('opacity','0');
62+
4663
backBox.css({
4764
'height': frontBox.height(),
4865
'position': 'absolute',
4966
'overflow': 'hidden'
5067
}).show(0, function(){
5168
flipContainer.addClass('flip');
5269
});
70+
5371
frontBox.delay(slideDelay).hide(0, function(){
5472
frontBox.css('display','none');
5573
backBox.css('position','relative').animate({
5674
height: backInner.height() + innerOuterDiff
5775
}, speed, function(){
5876
backBox.css({'height':'auto', 'overflow':'visible'});
77+
78+
if(applyWebkitCSSinJS) {
79+
// if speed + slideDelay is less than the CSS transition speed (400ms),
80+
// additional delay should be put on this
81+
flipContainer.css('-webkit-perspective','none');
82+
frontBox.css('-webkit-transform-style','flat');
83+
backBox.css('-webkit-transform-style','flat');
84+
};
85+
86+
backBox.find('.btn-edu').animate({'opacity':'1'}, 400);
5987
});
6088
});
6189
});
90+
91+
92+
6293
backTrigger.click(function(){
6394
backBox.css('position','absolute').show();
95+
96+
if(applyWebkitCSSinJS) {
97+
flipContainer.css('-webkit-perspective', webkitPerspective);
98+
frontBox.css('-webkit-transform-style','preserve-3d');
99+
backBox.css('-webkit-transform-style','preserve-3d');
100+
};
101+
64102
frontBox.css({
65103
'height': backBox.height(),
66104
'overflow': 'hidden'
67105
}).show(0, function(){
68106
flipContainer.removeClass('flip');
69107
});
108+
70109
backBox.delay(slideDelay).hide(0, function(){
71110
frontBox.animate({
72111
height: frontInner.height() + innerOuterDiff
73112
}, speed, function(){
74113
frontBox.css({'height':'auto', 'overflow':'visible'});
114+
115+
if(applyWebkitCSSinJS) {
116+
// if speed + slideDelay is less than the CSS transition speed (400ms),
117+
// additional delay should be put on this
118+
flipContainer.css('-webkit-perspective','none');
119+
frontBox.css('-webkit-transform-style','flat');
120+
backBox.css('-webkit-transform-style','flat');
121+
};
122+
123+
backBox.find('.btn-edu').css('opacity','0');
75124
});
76125
});
77126
});
127+
128+
78129
};

0 commit comments

Comments
 (0)