Skip to content

Commit

Permalink
Merge pull request #22 from gorriecoe/New-config-options-and-fix
Browse files Browse the repository at this point in the history
New config options and fix
  • Loading branch information
mediabeastnz committed Feb 5, 2016
2 parents 6845473 + 2cec904 commit 3485b79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
18 changes: 12 additions & 6 deletions code/DevTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,37 @@ public function init()
return;
}

$tasks = array(
$default_tasks = array(
'devbuild' => array(
'title' => 'Dev/Build',
'link' => 'dev/build',
'reset_time' => '5000',
'error_markup'=> '.xdebug-error,.xe-parse-error',
'error_handler' => 'newtab',
'success_markup'=> 'li[style="color: blue"],li[style="color: green"]',
'success_handler' => 'ignore'
)
);

$config_tasks = Config::inst()->get(__CLASS__, 'tasks');

if (is_array($config_tasks)) {
$tasks = array_merge($tasks, $config_tasks);
$tasks = array_merge($default_tasks, $config_tasks);
}else{
$tasks = $default_tasks;
}

foreach ($tasks as $item => $values) {

$attributes = array(
'class' => 'devbuild-trigger',
'data-title' => (isset($values['title']) ? $values['title'] : $item),
'data-link' => (isset($values['link']) ? $values['link'] : 'dev/build'),
'data-reset-time' => (isset($values['reset_time']) ? $values['reset_time'] : '5000'),
'data-error-handler' => (isset($values['error_handler']) ? $values['error_handler'] : 'newtab'),
'data-success-handler' => (isset($values['success_handler']) ? $values['success_handler'] : 'ignore')
'data-link' => (isset($values['link']) ? $values['link'] : $default_tasks['devbuild']['link']),
'data-reset-time' => (isset($values['reset_time']) ? $values['reset_time'] : $default_tasks['devbuild']['reset_time']),
'data-error-markup' => (isset($values['error_markup']) ? $values['error_markup'] : $default_tasks['devbuild']['error_markup']),
'data-error-handler' => (isset($values['error_handler']) ? $values['error_handler'] : $default_tasks['devbuild']['error_handler']),
'data-success-markup' => (isset($values['success_markup']) ? $values['success_markup'] : $default_tasks['devbuild']['success_markup']),
'data-success-handler' => (isset($values['success_handler']) ? $values['success_handler'] : $default_tasks['devbuild']['success_handler'])
);

// priority controls the ordering of the link in the stack. The
Expand Down
7 changes: 2 additions & 5 deletions javascript/LeftAndMain.Fancy-devbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@
url: $this.data('link')
})
.done(function( data, textStatus, xhr ) {
// remove classes
$this.removeClass("loading");

// search for any errors from returned data
if (data.search("ERROR") > 0) {
if ($(data).find($this.data('error-markup')).length > 0) {
completion_handler(data, $this.data('error-handler'));
// change text to show an error has occured
$this.attr('href', $this.data('link'))
Expand All @@ -76,7 +73,7 @@
} else {
completion_handler(data, $this.data('success-handler'));
// change text back to default
changes = $(data).find("li[style='color: blue'], li[style='color: green']").length;
changes = $(data).find($this.data('success-markup')).length;
$this.set_trigger(changes+" Changes occurred","success");
setTimeout(function(){
$this.reset_trigger();
Expand Down

0 comments on commit 3485b79

Please sign in to comment.