FIX: JS requirements load order

Custom requirement to be loaded after UploadField as it depends on
tmpl.js
Was crashing is IE and silently in Chrome
This commit is contained in:
colymba 2012-07-18 11:57:01 +03:00
parent 1460009272
commit a4a6a53503

View File

@ -152,10 +152,6 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js'); Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css'); Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
Requirements::javascript('GridFieldBulkImageUpload/javascript/GridFieldBulkImageUpload_downloadtemplate.js');
Requirements::javascript('GridFieldBulkImageUpload/javascript/GridFieldBulkImageUpload.js');
Requirements::css('GridFieldBulkImageUpload/css/GridFieldBulkImageUpload.css');
$crumbs = $this->Breadcrumbs(); $crumbs = $this->Breadcrumbs();
if($crumbs && $crumbs->count()>=2) $one_level_up = $crumbs->offsetGet($crumbs->count()-2); if($crumbs && $crumbs->count()>=2) $one_level_up = $crumbs->offsetGet($crumbs->count()-2);
@ -216,6 +212,11 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
$form->Backlink = $one_level_up->Link; $form->Backlink = $one_level_up->Link;
} }
// add these custom requirement after the UploadField is called -> depends on tmpl.js loaded with UploadField (avoid crashing)
Requirements::javascript('GridFieldBulkImageUpload/javascript/GridFieldBulkImageUpload.js');
Requirements::css('GridFieldBulkImageUpload/css/GridFieldBulkImageUpload.css');
Requirements::javascript('GridFieldBulkImageUpload/javascript/GridFieldBulkImageUpload_downloadtemplate.js');
$response = new SS_HTTPResponse($form->forTemplate()); $response = new SS_HTTPResponse($form->forTemplate());
$response->addHeader('Content-Type', 'text/plain'); $response->addHeader('Content-Type', 'text/plain');
$response->addHeader('X-Title', 'SilverStripe - Bulk '.$this->gridField->list->dataClass.' Image Upload'); $response->addHeader('X-Title', 'SilverStripe - Bulk '.$this->gridField->list->dataClass.' Image Upload');