Skip to content

Commit

Permalink
Incorporated the AMD pattern and RequireJS into site structure. Added…
Browse files Browse the repository at this point in the history
… Modules folder, and updated jQuery version. Next up, CanJS integration!
  • Loading branch information
jeffreytgilbert committed Jan 27, 2013
1 parent 32c89ab commit e414c2e
Show file tree
Hide file tree
Showing 16 changed files with 12,006 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public function handleRequest(){
public function renderHTML(){
$PageController = PageController::cast($this->getParentComponent()->getParentController());
$PageController->addCss('Components/Authentication/Pages/ForgotInfo');
$PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
$PageController->addJs('Libraries/jQuery.Validate/additional-methods');
$PageController->addJs('Components/Authentication/Pages/ForgotInfo');
// $PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
// $PageController->addJs('Libraries/jQuery.Validate/additional-methods');
$PageController->addJs('Components/Authentication/Pages/ForgotInfo');

if($this->getInput('Reset')->getString('reset_code') != ''){
$this->_page_body = $this->runCodeReturnOutput(Path::toComponents().$this->_component_name.'/Views/ForgotInfo/reset_layout.php', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function renderHTML(){
$PageController = PageController::cast($this->getParentComponent()->getParentController());
$PageController->addCss('Libraries/Zocial/zocial');
$PageController->addCss('Components/Authentication/Pages/Login');
$PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
// $PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
$PageController->addJs('Components/Authentication/Pages/Login');
// $PageController->addJs('Libraries/jQuery.Validate/additional-methods');
return parent::renderHTML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public function renderHTML(){
$PageController = PageController::cast($this->getParentComponent()->getParentController());
$PageController->addCss('Libraries/Zocial/zocial');
$PageController->addCss('Components/Authentication/Pages/Registration');
$PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
$PageController->addJs('Libraries/jQuery.Validate/additional-methods');
// $PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
// $PageController->addJs('Libraries/jQuery.Validate/additional-methods');
$PageController->addJs('Components/Authentication/Pages/Registration');
// $PageController->addJs('Libraries/jQuery.Validate/additional-methods');
return parent::renderHTML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function renderHTML(){
$PageController = PageController::cast($this->getParentComponent()->getParentController());
$PageController->addCss('Libraries/Zocial/zocial');
$PageController->addCss('Components/Authentication/Pages/Welcome');
$PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
// $PageController->addJs('Libraries/jQuery.Validate/jquery.validate');
$PageController->addJs('Components/Authentication/Pages/Welcome');

return parent::renderHTML();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct($ParentObject=null){

// add all the javascript files you want loaded every html page request here
$this->_extra_js = array_merge($this->_extra_js,array(
'default'
// Before editing this, make sure you can't just change the StartUp.js file to load your requirements for the template
));

// add all the css files you want loaded every html page request here
Expand Down
47 changes: 16 additions & 31 deletions Source/Applications/examplesite_com/Views/Themes/desktop.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@
}
</style>
<link rel="stylesheet" href="/css/Libraries/Bootstrap/bootstrap-responsive.min.css">

<!-- CSS Links <?php

$css = '-->';
<?php
$css = '';

foreach($Page->getRemoteCss() as $css_file) {
$css .= "\n".'
<link rel="stylesheet" type="text/css" href="'.$css_file.'">'."\n";
<link rel="stylesheet" type="text/css" href="'.$css_file.'">'."\n";
}

foreach($Page->getCss() as $css_file) {
if(File::exists($this_path.'/css/'.$css_file.'.css')){
$css .= "\n".'<link rel="stylesheet" type="text/css" href="/css/'.$css_file.'.css">'."\n";
$css .= "\t".'<link rel="stylesheet" type="text/css" href="/css/'.$css_file.'.css">'."\n";
} else {
$css .= pr('Error loading css file: '.File::osPath($this_path.'/css/'.$css_file.'.css'),1);
}
}
$css .= '<!-- End CSS Links ';

echo $css;
?> -->
?>

<script src="/js/Libraries/Modernizr/modernizr-2.6.1-respond-1.1.0.min.js"></script>
</head>

Expand Down Expand Up @@ -138,49 +138,34 @@
</div>
</footer>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/Libraries/jQuery/jquery-1.8.2.min.js"><\/script>');</script>
<script src="/js/Libraries/Bootstrap/bootstrap.min.js"></script>

<!-- JS Templates <?php

$templates = $Page->getTemplateEngine()->getArrayOfTemplatesWithIdsAsKeys();
$js_templates = '-->';
if(isset($this->_extra_js)){
foreach($templates as $template_name => $template) {
$js_templates .= "\n".'<script type="text/html" id="'.$template_name.'">'."\n".$template."\n".'</script>'."\n";
}
}
$js_templates .= '<!-- End JS Templates ';

?> -->

<!-- JS <?php
<script src="/js/Libraries/Require/require-jquery-2.1.4.js"></script>
<script src="/js/StartUp.js"></script>
<?php

$js = '-->';
$js = '';
foreach($Page->getRemoteJs() as $js_file) {
$js .= "\n".'<script src="'.$js_file.'"></script>'."\n";
$js .= "\t".'<script src="'.$js_file.'"></script>'."\n";
}

foreach($Page->getJs() as $js_file) {
if(File::exists($this_path.'/js/'.$js_file.'.js')){
$js .= "\n".'<script src="/js/'.$js_file.'.js"></script>'."\n";
$js .= "\t".'<script src="/js/'.$js_file.'.js"></script>'."\n";
} else {
$js .= pr('Error loading js file: '.File::osPath($this_path.'/js/'.$js_file.'.js'),1);
}

}
$js .= '<!-- End JS ';

echo $js;
?>

?> -->
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>

</body>
</html>

Expand Down
40 changes: 30 additions & 10 deletions Source/Framework/Startup.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ public function handlePageRequest(){

if(!isset($_GET['framework']) || !isset($_GET['framework']['requested_url'])){
Run::fromControllers('Pages/IndexPage.php');
$this->_pathing_info = array('controller_name'=>'Index');

$f = array(
'controller_name'=>'Index',
'controller_format'=>'html'
);

$this->_pathing_info = $f;
$Page = new IndexPage();
} else {
$f = $_GET['framework'];
Expand Down Expand Up @@ -345,6 +351,9 @@ public function handlePageRequest(){
if(isset($f['controller_name']) && $f['controller_name'] == ''){
// echo 'This is a request for the webroot';

$f['controller_name'] = 'Index';
$f['controller_format'] = (isset($f['controller_format']) && !empty($f['controller_format']))?$f['controller_format']:'html';

Run::fromControllers('Pages/IndexPage.php');
$Page = new IndexPage();
} else if(isset($f['controller_name'])) {
Expand Down Expand Up @@ -391,25 +400,36 @@ public function handlePageRequest(){
}
} else {
// echo 'Failsafe so something is always rendered'."\n";
$f['controller_name'] = 'Index';
$f['controller_format'] = (isset($f['controller_format']) && !empty($f['controller_format']))?$f['controller_format']:'html';
Run::fromControllers('Pages/IndexPage.php');
$Page = new IndexPage();
}

$this->_pathing_info = $f;
}

$not_rendered = true;
if(isset($f['controller_format']) && strtolower($f['controller_format']) != 'page' && strtolower($f['controller_format']) != 'html'){ // && $f['controller_format'] != 'html' // for optional link formatting
if(isset($f['controller_format'])){
$output_method = 'render'.$f['controller_format'];
if($Page instanceof $output_method.'Capable'){ // check to see if the page is capable of rendering this content

if(strtolower($f['controller_format']) == 'html' && is_a($Page, $f['controller_format'].'Capable')){
$Page->renderHTML();
$Page->renderThemedHTMLPage();
} else if(is_a($Page, $f['controller_format'].'Capable')){ // check to see if the page is capable of rendering this content
$Page->$output_method();
$not_rendered = false;
} else { // if not supported, error
header('HTTP/1.0 404 Not Found');
header('Status: 404 Not Found');
echo 404;
}

}

if($not_rendered) {
if($Page instanceof HTMLCapable){ // check to see if the page can render the default content type
} else {
if(is_a($Page, 'HTMLCapable')){
$Page->renderHTML();
$Page->renderThemedHTMLPage();
} else { // if not supported, error
header('HTTP/1.0 404 Not Found');
header('Status: 404 Not Found');
echo 404;
}
}

Expand Down
17 changes: 8 additions & 9 deletions www/js/Components/Authentication/Pages/ForgotInfo.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
////////////////////////////////////////////////////////////////
// This is the Login.js for the Authentication Component
////////////////////////////////////////////////////////////////

$(document).ready(function(){

ValidateForm('#RequestForm', ['#Request_email']);
ValidateForm('#ResetForm', ['#Reset_reset_code','#Reset_password']);

});
require(
['jquery', 'Modules/ValidateForm'],
function($, ValidateForm){
ValidateForm('#RequestForm', ['#Request_email']);
ValidateForm('#ResetForm', ['#Reset_reset_code','#Reset_password']);
}
);

15 changes: 7 additions & 8 deletions www/js/Components/Authentication/Pages/Login.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
////////////////////////////////////////////////////////////////
// This is the Login.js for the Authentication Component
////////////////////////////////////////////////////////////////

$(document).ready(function(){

ValidateForm('#LoginForm', ['#Login_unique_identifier','#Login_password']);

});
require(
['jquery', 'Modules/ValidateForm'],
function($, ValidateForm){
ValidateForm('#LoginForm', ['#Login_unique_identifier','#Login_password']);
}
);

15 changes: 7 additions & 8 deletions www/js/Components/Authentication/Pages/Registration.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
////////////////////////////////////////////////////////////////
// This is the Login.js for the Authentication Component
////////////////////////////////////////////////////////////////

$(document).ready(function(){

ValidateForm('#RegistrationForm', ['#Registration_unique_identifier','#Registration_password']);

});
require(
['jquery', 'Modules/ValidateForm'],
function($, ValidateForm){
ValidateForm('#RegistrationForm', ['#Registration_unique_identifier','#Registration_password']);
}
);

15 changes: 7 additions & 8 deletions www/js/Components/Authentication/Pages/Welcome.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
////////////////////////////////////////////////////////////////
// This is the Login.js for the Authentication Component
////////////////////////////////////////////////////////////////

$(document).ready(function(){

ValidateForm('#SubRegistrationForm', ['#SubRegistration_unique_identifier','#SubRegistration_password']);

});
require(
['jquery', 'Modules/ValidateForm'],
function($, ValidateForm){
ValidateForm('#SubRegistrationForm', ['#SubRegistration_unique_identifier','#SubRegistration_password']);
}
);

Loading

0 comments on commit e414c2e

Please sign in to comment.