Skip to content

Commit

Permalink
Merge pull request #1100 from ucfcdl/issue/convert-coffeescript-to-js
Browse files Browse the repository at this point in the history
convert coffeescript to js, clean up js & css usage
  • Loading branch information
iturgeon committed Mar 16, 2018
2 parents 4c18ea8 + 7dd563f commit 0ab66ea
Show file tree
Hide file tree
Showing 34 changed files with 4,308 additions and 488 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public/css/store.css
public/css/user.css
public/css/widget.css
public/css/upload.css
public/css/ng-modal.css

public/js/admin.js
public/js/author.js
Expand Down
4 changes: 3 additions & 1 deletion fuel/app/classes/controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ public function before()
$this->common_before();
if ( ! \RocketDuck\Perm_Manager::is_super_user() ) throw new \HttpNotFoundException;
Css::push_group('admin');
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'admin', 'author', 'student']);
Js::push_group(['angular', 'materia', 'admin']);
parent::before();
}

public function get_widget()
{
$this->theme->get_template()->set('title', 'Widget Admin');
$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/admin/widget')
->set('upload_enabled', Config::get('enable_uploader', false));
}

public function get_user()
{
$this->theme->get_template()->set('title', 'User Admin');
$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/admin/user');
}

Expand Down
5 changes: 2 additions & 3 deletions fuel/app/classes/controller/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public function get_import()
if (\Service_User::verify_session() !== true) throw new HttpNotFoundException;

Css::push_group(['core', 'media_catalog']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'dataTables', 'plupload']);
Js::push_group(['angular', 'jquery', 'materia', 'author', 'dataTables']);

Js::push_inline('var BASE_URL = "'.Uri::base().'";');
Js::push_inline('var WIDGET_URL = "'.Config::get('materia.urls.engines').'";');
Expand All @@ -62,6 +60,7 @@ public function get_import()
->set('title', 'Media Catalog')
->set('page_type', 'import');

$theme->set_partial('footer', 'partials/angular_alert');
$theme->set_partial('content', 'partials/catalog/media');

return Response::forge($theme->render());
Expand Down
5 changes: 2 additions & 3 deletions fuel/app/classes/controller/questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public function action_import()


Css::push_group(['core', 'question_catalog']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'dataTables']);
Js::push_group(['angular', 'jquery', 'materia', 'author', 'dataTables']);

Js::push_inline('var BASE_URL = "'.Uri::base().'";');
Js::push_inline('var WIDGET_URL = "'.Config::get('materia.urls.engines').'";');
Expand All @@ -28,6 +26,7 @@ public function action_import()
->set('title', 'Question Catalog')
->set('page_type', 'import');

$theme->set_partial('footer', 'partials/angular_alert');
$theme->set_partial('content', 'partials/catalog/question');

return Response::forge($theme->render());
Expand Down
4 changes: 2 additions & 2 deletions fuel/app/classes/controller/scores.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public function get_show($inst_id)

Css::push_group(['core', 'scores']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student', 'labjs']);
Js::push_group(['angular', 'materia', 'student', 'labjs']);

$token = \Input::get('token', false);
if ($token)
Expand All @@ -36,6 +35,7 @@ public function get_show($inst_id)
->set('title', 'Score Results')
->set('page_type', 'scores');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/score/full');
}

Expand Down
22 changes: 4 additions & 18 deletions fuel/app/classes/controller/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Controller_Site extends Controller
*/
public function action_index()
{

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);

$this->theme->get_template()
->set('title', 'Welcome to Materia')
Expand All @@ -25,14 +23,12 @@ public function action_index()
$spotlight = $this->theme->view('partials/spotlight');
$this->theme->set_partial('content', 'partials/homepage')
->set_safe('spotlight', $spotlight);
Js::push_group('jquery_ui');
Css::push_group('homepage');

}

public function action_permission_denied()
{
// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);

$this->theme->get_template()
->set('title', 'Permission Denied')
Expand All @@ -43,8 +39,7 @@ public function action_permission_denied()

public function action_help()
{
// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student']);
Js::push_group(['angular', 'materia']);

$this->theme->get_template()
->set('title', 'Help')
Expand All @@ -58,9 +53,6 @@ public function action_help()

public function action_403()
{
// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);

Css::push_group('404');

$this->theme->get_template()
Expand All @@ -81,9 +73,6 @@ public function action_403()
*/
public function action_404()
{
// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);

Css::push_group('404');

$this->theme->get_template()
Expand All @@ -104,9 +93,6 @@ public function action_404()
*/
public function action_500()
{
// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);

Css::push_group('500');

$this->theme->get_template()
Expand Down
15 changes: 6 additions & 9 deletions fuel/app/classes/controller/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public function get_login()
Event::trigger('request_login', $direct_login);

Css::push_group(['core', 'login']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student']);
Js::push_group(['angular', 'materia']);

$this->theme->get_template()
->set('title', 'Login')
Expand Down Expand Up @@ -92,8 +90,7 @@ public function get_profile()

Css::push_group(['core', 'profile']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student']);
Js::push_group(['angular', 'materia', 'student']);

// to properly fix the date display, we need to provide the raw server date for JS to access
$server_date = date_create('now', timezone_open('UTC'))->format('D, d M Y H:i:s');
Expand All @@ -103,6 +100,7 @@ public function get_profile()
->set('title', 'Profile')
->set('page_type', 'user profile');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/user/profile')
->set('me', \Model_User::find_current());
}
Expand All @@ -120,16 +118,15 @@ public function get_settings()
}

Css::push_group(['core', 'profile']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student', 'spinner']);
Js::push_group(['angular', 'materia', 'student']);

$this->theme->get_template()
->set('title', 'Settings')
->set('page_type', 'user profile settings');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/user/settings')
->set('me', \Model_User::find_current());
}

}
}
67 changes: 37 additions & 30 deletions fuel/app/classes/controller/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,11 @@ class Controller_Widgets extends Controller
*
* @login Not required
*/
public function get_index($type = null)
public function get_index()
{
// $type is an optional flag that provides optional display parameters for the catalog
// "all" displays all widgets in the database, not just the default "featured" ones
if (isset($type))
{
if ($type == 'all') // could be extended to include other options
{
Js::push_inline('var DISPLAY_TYPE = "'.$type.'";');
}
else throw new HttpNotFoundException;
}

Css::push_group(['core', 'widget_catalog']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);

$this->theme->get_template()
->set('title', 'Widget Catalog')
Expand All @@ -41,6 +29,13 @@ public function get_index($type = null)
$this->theme->set_partial('content', 'partials/widget/catalog');
}

public function get_all()
{
Js::push_inline('var DISPLAY_TYPE = "all";');
$this->get_index();
}


/**3
* Catalog page for an individual widget
*
Expand All @@ -58,8 +53,7 @@ public function get_detail()

Css::push_group(['widget_detail', 'core']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'fancybox']);
Js::push_group(['angular', 'jquery', 'materia', 'fancybox']);

$this->theme->get_template()
->set('title', 'Widget Details')
Expand Down Expand Up @@ -132,16 +126,15 @@ public function get_mywidgets()
}

Css::push_group(['core', 'my_widgets']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'tablock', 'spinner', 'jqplot', 'my_widgets', 'dataTables']);
Js::push_group(['angular', 'jquery', 'materia', 'author', 'tablock', 'spinner', 'jqplot', 'my_widgets', 'dataTables']);

Js::push_inline('var IS_STUDENT = '.(\Service_User::verify_session(['basic_author', 'super_user']) ? 'false;' : 'true;'));

$this->theme->get_template()
->set('title', 'My Widgets')
->set('page_type', 'my_widgets');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/my_widgets');
}

Expand Down Expand Up @@ -205,14 +198,19 @@ protected function show_editor($title, $widget, $inst_id=null)
{
$this->_disable_browser_cache = true;
Css::push_group(['core', 'widget_editor']);
Js::push_group(['angular', 'materia', 'author']);
if ( ! empty($widget->creator) && preg_match('/\.swf$/', $widget->creator))
{
// add swfobject if it's needed
Js::push_group('swfobject');
}

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'swfobject']);
$this->add_s3_config_to_response();
$this->theme->get_template()
->set('title', $title)
->set('page_type', 'create');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/widget/create')
->set('widget', $widget)
->set('inst_id', $inst_id);
Expand All @@ -226,8 +224,9 @@ protected function draft_not_playable()
->set('page_type', '');

$this->theme->set_partial('content', 'partials/widget/draft_not_playable');
$this->theme->set_partial('footer', 'partials/angular_alert');

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);
}

protected function retired()
Expand All @@ -237,8 +236,9 @@ protected function retired()
->set('page_type', '');

$this->theme->set_partial('content', 'partials/widget/retired');
$this->theme->set_partial('footer', 'partials/angular_alert');

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);
}

protected function no_attempts($inst)
Expand All @@ -248,6 +248,7 @@ protected function no_attempts($inst)
->set('title', 'Widget Unavailable')
->set('page_type', 'login');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/widget/no_attempts')
->set('classes', 'widget')
->set('attempts', $inst->attempts)
Expand All @@ -258,7 +259,7 @@ protected function no_attempts($inst)
->set('name', $inst->name)
->set('icon', Config::get('materia.urls.engines')."{$inst->widget->dir}img/icon-92.png"));

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);
// The styles for this are in login, should probably be moved?
Css::push_group('login');
}
Expand All @@ -270,9 +271,10 @@ protected function no_permission()
->set('title', 'Permission Denied')
->set('page_type', '');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/nopermission');

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);
}

protected function embedded_only($inst)
Expand All @@ -281,6 +283,7 @@ protected function embedded_only($inst)
->set('title', 'Widget Unavailable')
->set('page_type', 'login');

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/widget/embedded_only')
->set('classes', 'widget')

Expand All @@ -289,7 +292,7 @@ protected function embedded_only($inst)
->set('name', $inst->name)
->set('icon', Config::get('materia.urls.engines')."{$inst->widget->dir}img/icon-92.png"));

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author']);
Js::push_group(['angular', 'materia']);
// The styles for this are in login, should probably be moved?
Css::push_group('login');
}
Expand Down Expand Up @@ -406,7 +409,7 @@ protected function build_widget_login($login_title = null, $inst_id = null, $is_

if ($is_embedded) $this->_header = 'partials/header_empty';

Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'author', 'student']);
Js::push_group(['angular', 'materia', 'student']);
Css::push_group('login');
}

Expand Down Expand Up @@ -454,9 +457,12 @@ protected function build_widget_login_messages($inst)
protected function display_widget(\Materia\Widget_Instance $inst, $play_id=false, $is_embedded=false)
{
Css::push_group(['core', 'widget_play']);

// TODO: remove ngmodal, jquery, convert author to something else, materia is a mess
Js::push_group(['angular', 'ng_modal', 'jquery', 'materia', 'student', 'swfobject']);
Js::push_group(['angular', 'materia', 'student']);
if ( ! empty($inst->widget->player) && preg_match('/\.swf$/', $inst->widget->player))
{
// add swfobject if it's needed
Js::push_group('swfobject');
}

Js::push_inline('var PLAY_ID = "'.$play_id.'";');
$this->add_s3_config_to_response();
Expand All @@ -465,6 +471,7 @@ protected function display_widget(\Materia\Widget_Instance $inst, $play_id=false
->set('page_type', 'widget')
->set('html_class', $is_embedded ? 'embedded' : '' );

$this->theme->set_partial('footer', 'partials/angular_alert');
$this->theme->set_partial('content', 'partials/widget/play')
->set('inst_id', $inst->id);
}
Expand Down
Loading

0 comments on commit 0ab66ea

Please sign in to comment.