This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add requirejs support of ssa generator
- Loading branch information
Showing
7 changed files
with
197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ vendor/ | |
cache/ | ||
**/cache/ | ||
nbProject/ | ||
composer.phar | ||
|
||
############# | ||
## Windows detritus | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace ssa\converter; | ||
|
||
use ssa\converter\JavascriptConverter; | ||
|
||
/** | ||
* javascript converter for require js support | ||
* Warning SSA must be defined on require js config | ||
* | ||
* @author Thomas Deblock | ||
*/ | ||
class RequireJsJavascriptConverter extends JavascriptConverter { | ||
/** | ||
* create require js define | ||
* | ||
* @param type $className | ||
* @return type | ||
*/ | ||
protected function convertClass($className) { | ||
$txt = 'define([\'ssa\'], function(ssa){'.$this->END_OF_LINE; | ||
$txt .= parent::convertClass($className); | ||
|
||
return $txt; | ||
} | ||
|
||
/** | ||
* end the requirejs module | ||
* @param type $className | ||
* @return string | ||
*/ | ||
protected function endConvertClass($className) { | ||
return 'return ' . $className. ';'. $this->END_OF_LINE .'});'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
To change this license header, choose License Headers in Project Properties. | ||
To change this template file, choose Tools | Templates | ||
and open the template in the editor. | ||
--> | ||
<html> | ||
<head> | ||
<title> Page de test de ssa</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | ||
|
||
<script type="text/javascript" src="http://requirejs.org/docs/release/2.1.15/minified/require.js" ></script> | ||
<script type="text/javascript"> | ||
// configuration must containe a ssa link | ||
require.config({ | ||
paths: { | ||
// you must add ssa srcipt on your configuration | ||
"ssa": "../../../javascript/ssa", | ||
// warning if you don't use htaccess service param is like this /serviceName | ||
// if you use htacess you can have url like this /javascript/ssa/service/servicename.js who redirect on javascript.php | ||
"ssaService" : "javascript.php?type=requirejs&service=" | ||
} | ||
}); | ||
|
||
require( ["ssaService/helloWorldService"], | ||
function(helloWorldService) { | ||
helloWorldService.helloYou('deblockt').done(function(data) { | ||
$('#helloYou').html(data); | ||
}); | ||
|
||
$().ready(function(){ | ||
$('input[name="your_name"]').blur(function(){ | ||
helloWorldService.helloYou($(this).val()).done(function(data){ | ||
$('helloYou2').html(data); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
</script> | ||
</head> | ||
<body> | ||
<div>Hello world return : <span id="helloYou"></span> </div> | ||
<pre> | ||
<code class="javascript"> | ||
HelloWorld.helloYou('deblockt').done(function(data) { | ||
document.getElementById('helloYou').innerHTML = data; | ||
}); | ||
</code> | ||
</pre> | ||
<div> Hello You <input name="your_name" placeholder="Your name"/> : <span id="helloYou2"></span></div> | ||
<pre> | ||
<code class="javascript"> | ||
$('input[name="your_name"]').blur(function(){ | ||
HelloWorld.helloYou($(this).val()).done(function(data){ | ||
document.getElementById('helloYou2').innerHTML = data; | ||
}); | ||
}); | ||
</code> | ||
</pre> | ||
|
||
<form action="http://localhost:8080/ssa/test/ssa/toEndTest/run.php" method="POST" enctype="multipart/form-data"> | ||
<input type="text" name="service" value="HelloWorld.getFileContent"/> | ||
|
||
<input type="file" multiple="multiple" id="fileUpload1" name="file[]"/> | ||
<input type="file" multiple="multiple" id="fileUpload2" name="file[]"/> | ||
</form> | ||
|
||
|
||
|
||
|
||
<h3> complete source code </h3> | ||
|
||
<pre> | ||
<code class="javascript"> | ||
// configuration must containe a ssa link | ||
require.config({ | ||
paths: { | ||
// you must add ssa srcipt on your configuration | ||
"ssa": "../../../javascript/ssa", | ||
// warning if you don't use htaccess service param is like this /serviceName | ||
// if you use htacess you can have url like this /javascript/ssa/service/servicename.js who redirect on javascript.php | ||
"ssaService" : "javascript.php?type=requirejs&service=" | ||
} | ||
}); | ||
|
||
require( ["ssaService/helloWorldService"], | ||
function(helloWorldService) { | ||
helloWorldService.helloYou('deblockt').done(function(data) { | ||
$('#helloYou').html(data); | ||
}); | ||
|
||
$().ready(function(){ | ||
$('input[name="your_name"]').blur(function(){ | ||
helloWorldService.helloYou($(this).val()).done(function(data){ | ||
$('helloYou2').html(data); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
</code> | ||
</pre> | ||
</body> | ||
</html> |