Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6f89f4

Browse files
Merge pull request#131 from baminteractive/1.0.2
1.0.2 Release
2 parentsd2a70c9 +3cc6a09 commita6f89f4

20 files changed

+376
-235
lines changed

‎app/components/download-archive.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default Ember.Component.extend({
77
archiveLink:'',
88
initialMessage:'Generate Package',
99
buildingMessage:'Building Package…',
10-
tagName:'li',
10+
tagName:'span',
1111
linkMessage:function(){
1212
varmessage='';
1313
if(this.isBuilding){

‎app/components/generator-start.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
importEmberfrom'ember';
2+
3+
exportdefaultEmber.Component.extend({
4+
siteUrl:null,
5+
file:null,
6+
fileName:null,
7+
message:'',
8+
isSaving:false,
9+
actions:{
10+
startComplete:function(){
11+
varsiteUrl=this.get('siteUrl');
12+
varfile=this.get('file');
13+
if(!siteUrl&&!file){
14+
this.set('message','Please provide a URL or manifest file.');
15+
}else{
16+
this.set('message','');
17+
this.sendAction('action',siteUrl,file);
18+
}
19+
},
20+
uploadFile:function(file){
21+
this.set('file',file);
22+
this.set('fileName',file.name);
23+
this.sendAction('upload',file);
24+
}
25+
}
26+
});

‎app/components/generator-step.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default Ember.Component.extend({
55
nextStep:null,
66
isShowingBody:false,
77
showNextStep:true,
8-
allowToggle:false,
8+
allowToggle:true,
99
tagName:'li',
1010
classNames:['step'],
1111
classNameBindings:['stepId','isEnabled'],

‎app/components/manifest-upload.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default Ember.Component.extend({
1010
},
1111
actions:{
1212
uploadManifest:function(file){
13-
console.log(file);
1413
varself=this;
1514
vardata=this.generateFormData(file);
1615
this.$(".upload-file").attr("value",file.name);

‎app/controllers/generator.js‎

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,21 @@
22
importEmberfrom'ember';
33

44
exportdefaultEmber.Controller.extend({
5-
step1Complete:false,
5+
startReady:false,
6+
startComplete:function(){
7+
varstartReady=this.get('startReady');
8+
varmanifestId=this.get('model.manifestId');
9+
returnstartReady&&manifestId;
10+
}.property('startReady','model.isSaving','model.manifestId'),
11+
formattedManifest:function(){
12+
varmodel=this.get('model');
13+
varcode=model.get('manifest');
14+
returnnewEmber.Handlebars.SafeString('<code class=\'language-javascript\'>'+JSON.stringify(code,null,2)+'</code>');
15+
}.property('model.manifest'),
16+
isProcessing:function(){
17+
varmodel=this.get('model');
18+
returnmodel.get('isBuilding')||model.get('isSaving');
19+
}.property('model.isBuilding','model.isSaving'),
620
steps:Ember.Object.create({
721
step1:{
822
name:'step1',
@@ -15,14 +29,11 @@ export default Ember.Controller.extend({
1529
step3:{
1630
name:'step3',
1731
isCurrent:false
18-
},
19-
step4:{
20-
name:'step4',
21-
isCurrent:false
2232
}
2333
}),
2434
selectedDisplay:null,
2535
selectedOrientation:null,
36+
buildReady:false,
2637
valueOrEmptyString:function(value){
2738
if(value){
2839
returnvalue;
@@ -48,24 +59,26 @@ export default Ember.Controller.extend({
4859
};
4960
returndata;
5061
});
51-
5262
returncustomProps;
5363
}.property('model'),
5464
actions:{
5565
updateStep:function(currentStep,nextStep){
5666
if(currentStep){
5767
ga('send','event','item','click','generator-step-'+currentStep);
5868
this.set('steps.step'+currentStep+'.isCurrent',false);
59-
if(currentStep==='1'){
60-
this.set('step1Complete',true);
61-
this.model.create();
62-
}else{
63-
this.model.save();
64-
}
69+
this.model.save();
6570
}
6671
if(nextStep){
6772
this.set('steps.step'+nextStep+'.isCurrent',true);
6873
}
74+
},
75+
startOver:function(){
76+
this.set('startReady',false);
77+
returntrue;
78+
},
79+
startComplete:function(){
80+
this.set('startReady',true);
81+
returntrue;
6982
}
7083
}
7184
});

‎app/models/generator.js‎

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ export default Ember.Object.extend({
3838
orientation:{
3939
names:['any','natural','landscape','portrait','portrait-primary','portrait-secondary','landscape-primary','landscape-secondary']
4040
},
41-
formattedManifest:function(){
42-
returnnewEmber.Handlebars.SafeString("<code class='language-javascript'>"+JSON.stringify(this.get('manifest'),null,' ')+"</code>");
43-
}.property('manifest'),
4441
save:function(){
4542
this.set('isSaving',true);
4643
if(!this.manifestId){
@@ -49,6 +46,24 @@ export default Ember.Object.extend({
4946
this.update();
5047
}
5148
},
49+
processResult:function(result){
50+
this.set('manifest',result.content);
51+
this.set('manifestId',result.id);
52+
this.set('manifest.display','fullscreen');
53+
this.set('manifest.orientation','any');
54+
if(!this.get('manifest.icons')){
55+
this.set('manifest.icons',[]);
56+
}
57+
if(result.suggestions){
58+
this.set('suggestions',result.suggestions);
59+
}
60+
if(result.warnings){
61+
this.set('warnings',result.warnings);
62+
}
63+
if(result.errors){
64+
this.set('errors',result.errors);
65+
}
66+
},
5267
create:function(){
5368
varself=this;
5469
ajax({
@@ -58,74 +73,32 @@ export default Ember.Object.extend({
5873
dataType:'json',
5974
contentType:'application/json; charset=utf-8'
6075
}).then(function(result){
61-
self.set('manifest',result.content);
62-
self.set('manifestId',result.id);
63-
64-
//Set Defaults
65-
self.set('manifest.display','fullscreen');
66-
self.set('manifest.orientation','any');
67-
68-
if(!self.get('manifest.icons')){
69-
self.set('manifest.icons',[]);
70-
}
71-
72-
if(result.suggestions){
73-
self.set('suggestions',result.suggestions);
74-
}
75-
76-
if(result.warnings){
77-
self.set('warnings',result.warnings);
78-
}
79-
80-
if(result.errors){
81-
self.set('errors',result.errors);
82-
}
83-
84-
self.save();
85-
76+
self.processResult(result);
8677
self.set('isSaving',false);
87-
8878
}).catch(function(){
8979
self.set('isSaving',false);
9080
});
9181
},
9282
update:function(){
93-
varself=this,
94-
manifest=self.get('manifest');
95-
83+
varself=this;
84+
varmanifest=self.get('manifest');
9685
manifest=_.omit(manifest,function(prop){
97-
if(_.isString(prop)){
98-
return_.isEmpty(prop);
99-
}elseif(_.isObject(prop)){
100-
return_.isUndefined(prop);
101-
}
102-
103-
returnfalse;
86+
if(_.isString(prop)){
87+
return_.isEmpty(prop);
88+
}elseif(_.isObject(prop)){
89+
return_.isUndefined(prop);
90+
}
91+
returnfalse;
10492
});
105-
10693
ajax({
10794
url:config.APP.API_URL+'/manifests/'+this.get('manifestId'),
10895
type:'PUT',
10996
data:JSON.stringify(manifest),
11097
dataType:'json',
11198
contentType:'application/json; charset=utf-8'
11299
}).then(function(result){
113-
self.set('manifest',result.content);
114-
115-
if(result.suggestions){
116-
self.set('suggestions',result.suggestions);
117-
}
118-
119-
if(result.warnings){
120-
self.set('warnings',result.warnings);
121-
}
122-
123-
if(result.errors){
124-
self.set('errors',result.errors);
125-
}
126-
100+
self.processResult(result);
127101
self.set('isSaving',false);
128-
129102
}).catch(function(){
130103
self.set('isSaving',false);
131104
});
@@ -142,5 +115,28 @@ export default Ember.Object.extend({
142115
}).catch(function(){
143116
self.set('isBuilding',false);
144117
});
118+
},
119+
generateFormData:function(file){
120+
varformData=newFormData();
121+
formData.append('file',file);
122+
returnformData;
123+
},
124+
upload:function(file){
125+
varself=this;
126+
vardata=this.generateFormData(file);
127+
this.set('isSaving',true);
128+
ajax({
129+
url:config.APP.API_URL+'/manifests',
130+
type:'POST',
131+
data:data,
132+
contentType:false,
133+
processData:false,
134+
cache:false
135+
}).then(function(result){
136+
self.processResult(result);
137+
self.set('isSaving',false);
138+
}).catch(function(){
139+
self.set('isSaving',false);
140+
});
145141
}
146142
});

‎app/routes/generator.js‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export default Ember.Route.extend({
1919
Ember.$('footer').removeClass('is-small');
2020
},
2121
actions:{
22+
startComplete:function(siteUrl,file){
23+
varmodel=this.modelFor('generator');
24+
if(siteUrl){
25+
model.set('siteUrl',siteUrl);
26+
model.save();
27+
}elseif(file){
28+
model.upload(file);
29+
}
30+
},
2231
updateLogos:function(logos){
2332
varmodel=this.modelFor('generator');
2433
model.set('manifest.icons',logos);
@@ -30,28 +39,11 @@ export default Ember.Route.extend({
3039
model.build();
3140
},
3241
downloadArchive:function(archiveLink){
42+
varcontroller=this.controllerFor('generator');
43+
controller.set('buildReady',true);
3344
ga('send','event','item','click','generator-build-download');
3445
window.location.href=archiveLink;
3546
},
36-
updateManifest:function(result){
37-
varmodel=this.modelFor('generator');
38-
varcontroller=this.controllerFor('generator');
39-
controller.set('step1Complete',true);
40-
model.set('manifestId',result.id);
41-
model.set('manifest',result.content);
42-
if(result.content.display===undefined){
43-
model.set('manifest.display','fullscreen');
44-
}
45-
if(!result.content.orientation){
46-
model.set('manifest.orientation','any');
47-
}
48-
49-
if(!model.get('manifest.icons')){
50-
model.set('manifest.icons',[]);
51-
}
52-
53-
model.save();
54-
},
5547
updateModelProperty:function(name,value){
5648
varmodel=this.modelFor('generator');
5749
model.set('manifest.'+name,value);
@@ -73,6 +65,9 @@ export default Ember.Route.extend({
7365
updateModel:function(){
7466
varmodel=this.modelFor('generator');
7567
model.save();
68+
},
69+
startOver:function(){
70+
this.refresh();
7671
}
7772
}
7873
});

‎app/styles/_base/_b-elements.scss‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ button, .btn {
4444
background:$primary-accent;
4545
border:none;
4646
color:#fff;
47+
margin:0;
4748
padding:.5em1.125em;
4849
border-radius:5px;
4950
line-height:1.2em;
@@ -173,4 +174,4 @@ hr {
173174

174175
.hidden {
175176
display:none;
176-
}
177+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp