diff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.php index 181cf5ff25..c5e1d19549 100644 --- a/app/controllers/ChartController.php +++ b/app/controllers/ChartController.php @@ -1,5 +1,6 @@ _accounts = $accounts; $this->_journals = $journals; + $this->_preferences = $preferences; } /** @@ -34,98 +37,139 @@ class ChartController extends BaseController $current = clone $start; $return = []; $account = null; + $today = new Carbon\Carbon; if (!is_null($accountId)) { + /** @var \Account $account */ $account = $this->_accounts->find($accountId); } if (is_null($account)) { - $accounts = $this->_accounts->getActiveDefault(); + $pref = $this->_preferences->get('frontpageAccounts', []); + if ($pref->data == []) { + $accounts = $this->_accounts->getActiveDefault(); + } else { + $accounts = $this->_accounts->getByIds($pref->data); + } foreach ($accounts as $account) { - $return[] = ['name' => $account->name, 'data' => []]; + $return[] = ['name' => $account->name, 'id' => 'acc-' . $account->id, 'data' => []]; + } while ($current <= $end) { - // loop accounts: foreach ($accounts as $index => $account) { - $return[$index]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)]; + + + if ($current > $today) { + $return[$index]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)]; + } else { + $return[$index]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)]; + } } $current->addDay(); } } else { - $return[0] = ['name' => $account->name, 'data' => []]; + $return[0] = ['name' => $account->name, 'id' => $account->id, 'data' => []]; while ($current <= $end) { + if ($current > $today) { + $return[0]['data'][] = [$current->timestamp * 1000, $account->predict(clone $current)]; + } else { + $return[0]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)]; + } - $return[0]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)]; $current->addDay(); } - } +// // add an error bar as experiment: +// foreach($return as $index => $serie) { +// $err = [ +// 'type' => 'errorbar', +// 'name' => $serie['name'].' pred', +// 'linkedTo' => $serie['id'], +// 'data' => [] +// ]; +// foreach($serie['data'] as $entry) { +// $err['data'][] = [$entry[0],10,300]; +// } +// $return[] = $err; +// } + + return Response::json($return); } /** - * Get all budgets used in transaction(journals) this period: + * Return some beneficiary info for an account and a date. + * + * @param $name + * @param $day + * @param $month + * @param $year */ - public function homeBudgets() + public function homeAccountInfo($name, $day, $month, $year) { - list($start, $end) = tk::getDateRange(); - $data = [ - 'type' => 'pie', - 'name' => 'Expense: ', - 'data' => [] - ]; + $account = $this->_accounts->findByName($name); + $result = []; + $sum = 0; + if ($account) { + $date = \Carbon\Carbon::createFromDate($year, $month, $day); + $journals = $this->_journals->getByAccountAndDate($account, $date); - $result = $this->_journals->homeBudgetChart($start, $end); - - foreach ($result as $name => $amount) { - $data['data'][] = [$name, $amount]; + // loop all journals: + foreach ($journals as $journal) { + foreach ($journal->transactions as $transaction) { + $name = $transaction->account->name; + if ($transaction->account->id != $account->id) { + $result[$name] = isset($result[$name]) ? $result[$name] + floatval($transaction->amount) + : floatval($transaction->amount); + $sum += floatval($transaction->amount); + } + } + } } - return Response::json([$data]); - + return View::make('charts.info')->with('rows', $result)->with('sum', $sum); } - /** - * Get all categories used in transaction(journals) this period. - */ - public function homeCategories() - { + public function homeCategories() { list($start, $end) = tk::getDateRange(); + $account = null; + $result = []; + // grab all transaction journals in this period: + $journals = $this->_journals->getByDateRange($start,$end); - $result = $this->_journals->homeCategoryChart($start, $end); - $data = [ - 'type' => 'pie', - 'name' => 'Amount: ', - 'data' => [] - ]; + $result = []; + foreach ($journals as $journal) { + // has to be one: + + if (!isset($journal->transactions[0])) { + throw new FireflyException('Journal #' . $journal->id . ' has ' . count($journal->transactions) + . ' transactions!'); + } + $transaction = $journal->transactions[0]; + $amount = floatval($transaction->amount); + + // get budget from journal: + $budget = $journal->categories()->first(); + $budgetName = is_null($budget) ? '(no category)' : $budget->name; + + $result[$budgetName] = isset($result[$budgetName]) ? $result[$budgetName] + floatval($amount) : $amount; - foreach ($result as $name => $amount) { - $data['data'][] = [$name, $amount]; } - return Response::json([$data]); + unset($journal, $transaction, $budget, $amount); + + // sort + arsort($result); + $chartData = [ + ]; + foreach($result as $name => $value) { + $chartData[] = [$name, $value]; + } + + + + return Response::json($chartData); } - - /** - * get all beneficiaries used in transaction(journals) this period. - */ - public function homeBeneficiaries() - { - list($start, $end) = tk::getDateRange(); - $data = [ - 'type' => 'pie', - 'name' => 'Amount: ', - 'data' => [] - ]; - - $result = $this->_journals->homeBeneficiaryChart($start, $end); - - foreach ($result as $name => $amount) { - $data['data'][] = [$name, $amount]; - } - return Response::json([$data]); - - } -} \ No newline at end of file +} \ No newline at end of file diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 97f31f5106..948494bf1d 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -30,24 +30,10 @@ class HomeController extends BaseController */ public function index() { - // get list setting: - $pref = $this->_preferences->get('frontpageAccounts', []); - // get the accounts to display on the home screen: $count = $this->_accounts->count(); - if ($pref->data == []) { - $list = $this->_accounts->getActiveDefault(); - } else { - $list = $this->_accounts->getByIds($pref->data); - } - - // get transactions for each account: - foreach ($list as $account) { - $account->transactionList = $this->_journal->getByAccount($account, 10); - } - // build the home screen: - return View::make('index')->with('count', $count)->with('accounts', $list); + return View::make('index')->with('count', $count); } } \ No newline at end of file diff --git a/app/controllers/MigrationController.php b/app/controllers/MigrationController.php index cecad119ed..4b87445824 100644 --- a/app/controllers/MigrationController.php +++ b/app/controllers/MigrationController.php @@ -40,6 +40,8 @@ class MigrationController extends BaseController exit(); } } + echo 'home'; + exit(); } /** diff --git a/app/database/migrations/2014_07_17_183717_create_limits_table.php b/app/database/migrations/2014_07_17_183717_create_limits_table.php new file mode 100644 index 0000000000..7a91836c49 --- /dev/null +++ b/app/database/migrations/2014_07_17_183717_create_limits_table.php @@ -0,0 +1,41 @@ +increments('id'); + $table->timestamps(); + $table->integer('component_id')->unsigned(); + $table->date('startdate'); + $table->date('enddate'); + $table->decimal('amount',10,2); + + // connect component + $table->foreign('component_id') + ->references('id')->on('components') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('limits'); + } + +} diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php index 5ee1a572cb..598ef2489d 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php +++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php @@ -167,127 +167,16 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito } - public function homeBudgetChart(\Carbon\Carbon $start, \Carbon\Carbon $end) - { - return $this->homeComponentChart($start, $end, 'Budget'); - } - - public function homeComponentChart(\Carbon\Carbon $start, \Carbon\Carbon $end, $chartType) - { - - // lets make this simple. - $types = []; - foreach (\TransactionType::whereIn('type', ['Withdrawal'])->get() as $t) { - $types[] = $t->id; - } - unset($t); - - // get all journals, partly filtered: - $journals = \TransactionJournal:: - with( - ['components' => function ($q) use ($chartType) { - $q->where('class', $chartType); - }, 'transactions' => function ($q) { - $q->where('amount', '>', 0); - }] - ) - ->after($start)->before($end) - ->where('completed', 1) - ->whereIn('transaction_type_id', $types) - ->get(['transaction_journals.*']); - unset($types); - $result = []; - - - foreach ($journals as $journal) { - // has to be one: - if (!isset($journal->transactions[0])) { - throw new FireflyException('Journal #' . $journal->id . ' has ' . count($journal->transactions) - . ' transactions!'); - } - $transaction = $journal->transactions[0]; - $amount = floatval($transaction->amount); - - - // MIGHT be one: - $budget = isset($journal->components[0]) ? $journal->components[0] : null; - if (!is_null($budget)) { - $name = $budget->name; - } else { - $name = '(no budget)'; - } - $result[$name] = isset($result[$name]) ? $result[$name] + $amount : $amount; - - } - unset($journal, $transaction, $budget, $name, $amount); - - // sort - arsort($result); - - return $result; - } - - public function homeCategoryChart(\Carbon\Carbon $start, \Carbon\Carbon $end) - { - return $this->homeComponentChart($start, $end, 'Category'); - } - - public function homeBeneficiaryChart(\Carbon\Carbon $start, \Carbon\Carbon $end) - { - $result = []; - - // lets make this simple. - $types = []; - foreach (\TransactionType::whereIn('type', ['Withdrawal'])->get() as $t) { - $types[] = $t->id; - } - unset($t); - - // account type we want to see: - $accountType = \AccountType::where('description', 'Beneficiary account')->first(); - $accountTypeID = $accountType->id; - - // get all journals, partly filtered: - $journals = \TransactionJournal:: - with( - ['transactions', 'transactions.account' => function ($q) use ($accountTypeID) { - $q->where('account_type_id', $accountTypeID); - }] - ) - ->after($start)->before($end) - ->whereIn('transaction_type_id', $types) - ->orderBy('date', 'DESC') - ->orderBy('id', 'DESC') - ->get(['transaction_journals.*']); - foreach ($journals as $journal) { - foreach ($journal->transactions as $t) { - if (!is_null($t->account)) { - $name = $t->account->name; - $amount = floatval($t->amount) < 0 ? floatval($t->amount) * -1 : floatval($t->amount); - - $result[$name] = isset($result[$name]) ? $result[$name] + $amount : $amount; - } - } - } - // sort result: - arsort($result); - - - return $result; - } - public function getByAccount(\Account $account, $count = 25) { $accountID = $account->id; - $query = \TransactionJournal:: - with( - [ - 'transactions', - 'transactioncurrency', - 'transactiontype' - ] - ) - ->take($count) + $query = \Auth::user()->transactionjournals()->with( + [ + 'transactions', + 'transactioncurrency', + 'transactiontype' + ] + ) ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->where('accounts.id', $accountID) @@ -298,5 +187,51 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito return $query; } + public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end) + { + // lets make this simple. + $types = []; + foreach (\TransactionType::whereIn('type', ['Withdrawal'])->get() as $t) { + $types[] = $t->id; + } + unset($t); + + // get all journals, partly filtered: + $journals = \TransactionJournal:: + with( + ['components', 'transactions' => function ($q) { + $q->where('amount', '>', 0); + }] + ) + ->after($start)->before($end) + ->where('completed', 1) + ->whereIn('transaction_type_id', $types) + ->get(['transaction_journals.*']); + unset($types); + return $journals; + } + + public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date) + { + $accountID = $account->id; + $query = \Auth::user()->transactionjournals()->with( + [ + 'transactions', + 'transactions.account', + 'transactioncurrency', + 'transactiontype' + ] + ) + ->distinct() + ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') + ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') + ->where('transactions.account_id', $accountID) + ->where('transaction_journals.date', $date->format('Y-m-d')) + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.id', 'DESC') + ->get(['transaction_journals.*']); + return $query; + } + } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php index 56ef614561..9963dae8a4 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php +++ b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php @@ -13,12 +13,8 @@ interface TransactionJournalRepositoryInterface public function getByAccount(\Account $account, $count = 25); - public function homeBudgetChart(\Carbon\Carbon $start, \Carbon\Carbon $end); + public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date); - public function homeCategoryChart(\Carbon\Carbon $start, \Carbon\Carbon $end); - - public function homeBeneficiaryChart(\Carbon\Carbon $start, \Carbon\Carbon $end); - - public function homeComponentChart(\Carbon\Carbon $start, \Carbon\Carbon $end, $chartType); + public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end); } \ No newline at end of file diff --git a/app/models/Account.php b/app/models/Account.php index cb4e23754d..8e5b834bb1 100644 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -88,10 +88,14 @@ class Account extends Ardent ->leftJoin( 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' ) - ->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount') + ->where('transaction_journals.date', '<', $date->format('Y-m-d'))->sum('transactions.amount') ); } + public function predict(\Carbon\Carbon $date) { + return null; + } + /** * Transactions. * diff --git a/app/models/Component.php b/app/models/Component.php index aae42549d2..a06abc3215 100644 --- a/app/models/Component.php +++ b/app/models/Component.php @@ -42,6 +42,10 @@ class Component extends Firefly\Database\SingleTableInheritanceEntity return $this->belongsToMany('Transaction'); } + public function limits() { + return $this->belongsTo('Limit'); + } + public function transactionjournals() { return $this->belongsToMany('TransactionJournal'); diff --git a/app/models/Limit.php b/app/models/Limit.php new file mode 100644 index 0000000000..5ffef56c58 --- /dev/null +++ b/app/models/Limit.php @@ -0,0 +1,41 @@ + 'required|exists:components,id', + 'startdate' => 'required|date', + 'enddate' => 'required|date', + 'amount' => 'numeric|required|min:0.01' + + ]; + + public static $factory + = [ + 'component_id' => 'factory|Budget', + 'startdate' => 'date', + 'enddate' => 'date', + 'amount' => '100' + ]; + + public function component() + { + return $this->belongsTo('Component'); + } + + public function budget() + { + return $this->belongsTo('Budget', 'component_id'); + } + + public function getDates() + { + return ['created_at', 'updated_at', 'startdate', 'enddate']; + } + + +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index ba0d8f8e03..c623f869e1 100644 --- a/app/routes.php +++ b/app/routes.php @@ -7,9 +7,9 @@ Route::group(['before' => 'auth'], function () { // chart controller Route::get('/chart/home/account/{account?}', ['uses' => 'ChartController@homeAccount', 'as' => 'chart.home']); - Route::get('/chart/home/budgets', ['uses' => 'ChartController@homeBudgets', 'as' => 'chart.budgets']); - Route::get('/chart/home/beneficiaries', ['uses' => 'ChartController@homeBeneficiaries', 'as' => 'chart.beneficiaries']); Route::get('/chart/home/categories', ['uses' => 'ChartController@homeCategories', 'as' => 'chart.categories']); + Route::get('/chart/home/info/{account}/{day}/{month}/{year}', ['uses' => 'ChartController@homeAccountInfo', 'as' => 'chart.info']); + // preferences controller Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']); @@ -26,6 +26,9 @@ Route::group(['before' => 'auth'], function () { Route::get('/accounts/create', ['uses' => 'AccountController@create', 'as' => 'accounts.create']); Route::get('/accounts/{account}', ['uses' => 'AccountController@show', 'as' => 'accounts.show']); + // budget controller + Route::get('/bugets',['uses' => 'BudgetController@index','as' => 'budgets.index']); + // JSON controller: Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']); Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']); diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.php index 62c42829f8..11d770ce15 100644 --- a/app/tests/controllers/HomeControllerTest.php +++ b/app/tests/controllers/HomeControllerTest.php @@ -13,64 +13,12 @@ class HomeControllerTest extends TestCase View::shouldReceive('share'); View::shouldReceive('make')->with('index')->once()->andReturn(\Mockery::self()) ->shouldReceive('with')->once() // Pass a 'with' parameter - ->with('count', 0) - ->andReturn(Mockery::self()) - ->shouldReceive('with')->once() // another 'with' parameter. - ->with('accounts',[]) - ->andReturn(Mockery::self()) - ; + ->with('count', 0); Auth::shouldReceive('check')->andReturn(true); // mock account repository $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); $accounts->shouldReceive('count')->andReturn(0); - $accounts->shouldReceive('getActiveDefault')->andReturn([]); - - $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); - $preferences->shouldReceive('get')->with('frontpageAccounts',[])->andReturn(new \Preference)->once(); - - // call - $this->call('GET', '/'); - - // test - $this->assertResponseOk(); - } - - public function testIndexWithAccount() { - - // mock Account - $account = $this->mock('Account'); - $account->shouldReceive('setAttribute')->with('transactionList',[]); - - // mock account repository - $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); - $accounts->shouldReceive('count')->andReturn(0); - $accounts->shouldReceive('getByIds')->andReturn([$account]); - - // mock: - View::shouldReceive('share'); - View::shouldReceive('make')->with('index')->once()->andReturn(\Mockery::self()) - ->shouldReceive('with')->once() // Pass a 'with' parameter - ->with('count', 0) - ->andReturn(Mockery::self()) - ->shouldReceive('with')->once() // another 'with' parameter. - ->with('accounts',[$account]) - ->andReturn(Mockery::self()) - ; - - - - // mock transaction journal - $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface'); - $tj->shouldReceive('getByAccount')->with($account,10)->andReturn([]); - - // mock preferences helper: - $pref = $this->mock('Preference'); - $pref->shouldReceive('getAttribute', 'data')->andReturn([1]); - - - $preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface'); - $preferences->shouldReceive('get')->with('frontpageAccounts',[])->andReturn($pref)->once(); // call $this->call('GET', '/'); diff --git a/app/views/charts/info.blade.php b/app/views/charts/info.blade.php new file mode 100644 index 0000000000..8bcf421910 --- /dev/null +++ b/app/views/charts/info.blade.php @@ -0,0 +1,12 @@ + + + + + + @foreach($rows as $name => $amount) + + + + + @endforeach +
Total{{mf($sum*-1)}}
{{{$name}}}{{mf($amount*-1)}}
\ No newline at end of file diff --git a/app/views/index.blade.php b/app/views/index.blade.php index b838fa5ade..3c71c84538 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -35,6 +35,7 @@

+
Bla bla

Migrate from Firefly II

@@ -54,64 +55,27 @@
- @foreach($accounts as $index => $account) -
-
-

- Go to {{{$account->name}}} -

- +
+
- @if($index % 2 == 1) -
- @endif - @endforeach
-
- @foreach($accounts as $index => $account) -
-

{{$account->name}}

- @include('transactions.journals',['journals' => $account->transactionList]) -
- @if($index % 2 == 1) -
- @endif - @endforeach -
- - - -
- - - - -
-
-
-
-
-
-
-
-
-
-
-




- - @endif @stop @section('scripts') - + + + + +@stop +@section('styles') + @stop \ No newline at end of file diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.php index 8776ac8607..f7c957e13c 100644 --- a/app/views/layouts/default.blade.php +++ b/app/views/layouts/default.blade.php @@ -10,6 +10,7 @@ + @yield('styles') diff --git a/app/views/partials/menu/home.blade.php b/app/views/partials/menu/home.blade.php index 496d959ebc..1714446b61 100644 --- a/app/views/partials/menu/home.blade.php +++ b/app/views/partials/menu/home.blade.php @@ -21,8 +21,8 @@ $r = Route::current()->getName();
"+this[this.numberPosition].innerHTML}}},initSlideshow:function(){if(!this.last){for(var c=0;cthis.x.get("opos")+this.x.get("osize"));var g=(k.y+k.hthis.y.get("opos")+this.y.get("osize"))}var d=hs.getWrapperKey(e[f]);if(!j&&!g&&d!=this.key){if(!h){e[f].setAttribute("hidden-by","["+this.key+"]");e[f].origProp=e[f].style[a];e[f].style[a]="hidden"}else{if(h.indexOf("["+this.key+"]")==-1){e[f].setAttribute("hidden-by",h+"["+this.key+"]")}}}else{if((h=="["+this.key+"]"||hs.focusKey==d)&&d!=this.key){e[f].setAttribute("hidden-by","");e[f].style[a]=e[f].origProp||""}else{if(h&&h.indexOf("["+this.key+"]")>-1){e[f].setAttribute("hidden-by",h.replace("["+this.key+"]",""))}}}}}}}},focus:function(){this.wrapper.style.zIndex=hs.zIndexCounter+=2;for(var a=0;ae.parentNode.offsetWidth){e.style.width="100%"}}else{if(e.parentNode!=this.overlayBox){this.overlayBox.appendChild(e)}}if(/left$/.test(f)){e.style.left=b+"px"}if(/center$/.test(f)){hs.setStyles(e,{left:"50%",marginLeft:(b-Math.round(e.offsetWidth/2))+"px"})}if(/right$/.test(f)){e.style.right=-b+"px"}if(/^leftpanel$/.test(f)){hs.setStyles(e,{right:"100%",marginRight:this.x.cb+"px",top:-this.y.cb+"px",bottom:-this.y.cb+"px",overflow:"auto"});this.x.p1=e.offsetWidth}else{if(/^rightpanel$/.test(f)){hs.setStyles(e,{left:"100%",marginLeft:this.x.cb+"px",top:-this.y.cb+"px",bottom:-this.y.cb+"px",overflow:"auto"});this.x.p2=e.offsetWidth}}var d=e.parentNode.offsetHeight;e.style.height="auto";if(c&&e.offsetHeight>d){e.style.height=hs.ieLt7?d+"px":"100%"}if(/^top/.test(f)){e.style.top=a+"px"}if(/^middle/.test(f)){hs.setStyles(e,{top:"50%",marginTop:(a-Math.round(e.offsetHeight/2))+"px"})}if(/^bottom/.test(f)){e.style.bottom=-a+"px"}if(/^above$/.test(f)){hs.setStyles(e,{left:(-this.x.p1-this.x.cb)+"px",right:(-this.x.p2-this.x.cb)+"px",bottom:"100%",marginBottom:this.y.cb+"px",width:"auto"});this.y.p1=e.offsetHeight}else{if(/^below$/.test(f)){hs.setStyles(e,{position:"relative",left:(-this.x.p1-this.x.cb)+"px",right:(-this.x.p2-this.x.cb)+"px",top:"100%",marginTop:this.y.cb+"px",width:"auto"});this.y.p2=e.offsetHeight;e.style.position="absolute"}}},getOverlays:function(){this.getInline(["heading","caption"],true);this.getNumber();if(this.caption){hs.fireEvent(this,"onAfterGetCaption")}if(this.heading){hs.fireEvent(this,"onAfterGetHeading")}if(this.heading&&this.dragByHeading){this.heading.className+=" highslide-move"}if(hs.showCredits){this.writeCredits()}for(var a=0;a=5.5){c=c.replace(new RegExp("]*>","gi"),"").replace(new RegExp("]*>.*?<\/script>","gi"),"");if(this.iframe){var f=this.iframe.contentDocument;if(!f&&this.iframe.contentWindow){f=this.iframe.contentWindow.document}if(!f){var g=this;setTimeout(function(){g.loadHTML()},25);return}f.open();f.write(c);f.close();try{c=f.getElementById(this.id).innerHTML}catch(d){try{c=this.iframe.document.getElementById(this.id).innerHTML}catch(d){}}hs.discardElement(this.iframe)}else{b=/(]*>|<\/body>)/ig;if(b.test(c)){c=c.split(b)[hs.ieLt9?1:2]}}}hs.getElementByClass(this.content,"DIV","highslide-body").innerHTML=c;this.onLoad();for(var a in this){this[a]=null}}};hs.Slideshow=function(c,b){if(hs.dynamicallyUpdateAnchors!==false){hs.updateAnchors()}this.expKey=c;for(var a in b){this[a]=b[a]}if(this.useControls){this.getControls()}if(this.thumbstrip){this.thumbstrip=hs.Thumbstrip(this)}};hs.Slideshow.prototype={getControls:function(){this.controls=hs.createElement("div",{innerHTML:hs.replaceLang(hs.skin.controls)},null,hs.container);var b=["play","pause","previous","next","move","full-expand","close"];this.btn={};var c=this;for(var a=0;a0){F=0}if(C>0){C=0}if(C0?G[L-1].parentNode[B]:w[B],A=w[B]+w[H]+(G[L+1]?G[L+1].parentNode[H]:0);if(A>x-v){C=x-A}else{if(J<-v){C=-J}}}var E=w[B]+(w[H]-g[H])/2+C;hs.animate(s,h?{left:C}:{top:C},null,"easeOutQuad");hs.animate(g,h?{left:E}:{top:E},null,"easeOutQuad");l.style.display=C<0?"block":"none";t.style.display=(C>F)?"block":"none"}var j=hs.anchors.groups[hs.expanders[k.expKey].slideshowGroup||"none"],f=k.thumbstrip,m=f.mode||"horizontal",u=(m=="float"),o=u?["div","ul","li","span"]:["table","tbody","tr","td"],h=(m=="horizontal"),r=hs.createElement("div",{className:"highslide-thumbstrip highslide-thumbstrip-"+m,innerHTML:'
<'+o[0]+"><"+o[1]+">
'},{display:"none"},hs.container),e=r.childNodes,n=e[0],l=e[1],t=e[2],g=e[3],s=n.firstChild,a=r.getElementsByTagName(o[1])[0],b;for(var q=0;q35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('j(!f){m f={1a:{5v:\'3R\',3E:\'5E...\',3q:\'3s 1q 5N\',3m:\'3s 1q 1B 2G\'},2T:\'W/5t/\',2j:\'5x.3u\',3e:\'5O.3u\',4s:3b,4o:3b,6e:15,62:15,5R:15,5X:15,23:4R,3y:0.4V,3U:3X,3z:3X,r:[],2B:[\'3Z\',\'3U\',\'3z\',\'2d\',\'2C\',\'4v\',\'4I\',\'P\',\'41\',\'40\',\'U\'],1r:[],5n:{},29:[],1y:/5k\\/4\\.0/.2X(37.34)?8:3a((37.34.2o().3Q(/.+(?:53|4Z|6c|1c)[\\/: ]([\\d.]+)/)||[0,\'0\'])[1]),1c:(v.56&&!1l.44),49:/57/.2X(37.34),$:k(1f){j(1f)o v.55(1f)},2D:k(39,1p){39[39.17]=1p},19:k(3D,1N,1o,3d,3C){m h=v.19(3D);j(1N)f.25(h,1N);j(3C)f.T(h,{4Y:0,51:\'2N\',2I:0});j(1o)f.T(h,1o);j(3d)3d.1M(h);o h},25:k(h,1N){S(m x 1U 1N)h[x]=1N[x];o h},T:k(h,1o){S(m x 1U 1o){j(f.1w&&x==\'Z\'){j(1o[x]>0.5a)h.z.5b(\'2g\');O h.z.2g=\'3v(Z=\'+(1o[x]*2p)+\')\'}O h.z[x]=1o[x]}},2Q:k(h,u,12){m 1x,1P,1D;j(H 12!=\'4j\'||12===A){m 1T=4l;12={1F:1T[2],P:1T[3],2F:1T[4]}}j(H 12.1F!=\'3K\')12.1F=3b;12.P=1s[12.P]||1s.3G;12.2t=f.25({},u);S(m 16 1U u){m e=1E f.C(h,12,16);1x=3a(f.33(h,16))||0;1P=3a(u[16]);1D=16!=\'Z\'?\'K\':\'\';e.1m(1x,1P,1D)}},33:k(h,u){j(h.z[u]){o h.z[u]}O j(v.3t){o v.3t.5h(h,A).5d(u)}O{j(u==\'Z\')u=\'2g\';m 1p=h.5c[u.1Z(/\\-(\\w)/g,k(a,b){o b.5e()})];j(u==\'2g\')1p=1p.1Z(/3v\\(Z=([0-9]+)\\)/,k(a,b){o b/2p});o 1p===\'\'?1:1p}},2l:k(){m d=v,w=1l,1S=d.3c&&d.3c!=\'4f\'?d.1K:d.2f,1w=f.1c&&(f.1y<9||H 3Y==\'1g\');m V=1w?1S.3B:(d.1K.3B||2c.4C),14=1w?1S.4B:2c.4D;f.1Q={V:V,14:14,2V:1w?1S.2V:3Y,2S:1w?1S.2S:4J};o f.1Q},4u:k(h){m p={x:h.3F,y:h.3T};2Z(h.3S){h=h.3S;p.x+=h.3F;p.y+=h.3T;j(h!=v.2f&&h!=v.1K){p.x-=h.2V;p.y-=h.2S}}o p},4W:k(a,R,1m,4k){j(!a)a=f.19(\'a\',A,{2H:\'2N\'},f.1i);j(H a.1Y==\'k\')o R;10{1E f.1X(a,R,1m);o 18}X(e){o L}},3I:k(a,20){a.1Y=a.1W;m p=a.1Y?a.1Y():A;a.1Y=A;o(p&&H p[20]!=\'1g\')?p[20]:(H f[20]!=\'1g\'?f[20]:A)},4T:k(a){m U=f.3I(a,\'U\');j(U)o U;o a.2e},2R:k(d){j(d)f.3o.1M(d);f.3o.3r=\'\'},3M:k(3f,2v){m h,31=/^W-B-([0-9]+)$/;h=3f;2Z(h.2i){j(h.1f&&31.2X(h.1f))o h.1f.1Z(31,"$1");h=h.2i}j(!2v){h=3f;2Z(h.2i){j(h.4M&&f.3L(h)){S(m E=0;E=5.G.1F+5.2K){5.1J=5.1P;5.D=5.2M=1;5.2L();5.G.2t[5.u]=L;m 2E=L;S(m i 1U 5.G.2t)j(5.G.2t[i]!==L)2E=18;j(2E){j(5.G.2F)5.G.2F.3N(5.N)}o 18}O{m n=t-5.2K;5.2M=n/5.G.1F;5.D=5.G.P(n,0,1,5.G.1F);5.1J=5.1x+((5.1P-5.1x)*5.D);5.2L()}o L}};f.25(f.C,{1n:{Z:k(C){f.T(C.N,{Z:C.1J})},3P:k(C){10{j(C.N.z&&C.N.z[C.u]!=A)C.N.z[C.u]=C.1J+C.1D;O C.N[C.u]=C.1J}X(e){}}}});f.2n=k(q,1b){5.q=q;5.1b=1b;5.1H=1b==\'x\'?\'5A\':\'5y\';5.1t=5.1H.2o();5.24=1b==\'x\'?\'65\':\'6d\';5.4y=5.24.2o();5.2z=1b==\'x\'?\'63\':\'5U\';5.5T=5.2z.2o()};f.2n.2P={M:k(E){5Q(E){1O\'2J\':o 5.Q+5.1u+(5.t-f.I[\'2h\'+5.1H])/2;1O\'1e\':o 5.21+2*5.1j;1O\'3g\':o 5.2a-5.1A-5.2b;1O\'60\':o 5.M(\'3g\')-2*5.1j;1O\'5f\':o 5.D;1O\'4L\':o 5.M(\'1e\')}},2w:k(){5.1j=(5.q.F[\'2h\'+5.1H]-5.t)/2;5.2b=f[\'2I\'+5.2z]},2y:k(){5.t=5.q.h[5.1t]?4U(5.q.h[5.1t]):5.q.h[\'2h\'+5.1H];5.Q=5.q.Q[5.1b];5.1u=(5.q.h[\'2h\'+5.1H]-5.t)/2;j(5.Q==0||5.Q==-1){5.Q=(f.1Q[5.1t]/2)+f.1Q[\'1k\'+5.24]}},2x:k(){m q=5.q;5.28=\'4G\';5.D=5.Q-5.1j+5.1u;j(5.2C&&5.1b==\'x\')q.2d=1s.3A(q.2d||5.Y,q.2C*5.Y/q.y.Y);5.21=1s.3A(5.Y,q[\'5m\'+5.1H]||5.Y);5.52=5.Y;5.1A=f[\'2I\'+5.24];5.1k=f.1Q[\'1k\'+5.24];5.2a=f.1Q[5.1t]},5Z:k(i){m q=5.q;5.21=i;q.F.z[5.1t]=i+\'K\';q.B.z[5.1t]=5.M(\'1e\')+\'K\'},54:k(i){5.D=i;5.q.B.z[5.4y]=i+\'K\'}};f.1X=k(a,R,1m,22){j(v.5j&&f.1c&&!f.2O){f.1v(v,\'1I\',k(){1E f.1X(a,R,1m,22)});o}5.a=a;5.1m=1m;5.22=22||\'2G\';5.4X=!5.4H;f.4w();m E=5.E=f.r.17;S(m i=0;ip.1k+p.2a-p.2b){j(!47&&3l){}O j(p.M(\'1e\')Highslide JS",creditsTitle:"Go to the Highslide JS homepage",restoreTitle:"Click to close image, click and drag to move. Use arrow keys for next and previous."},graphicsDir:"highslide/graphics/",expandCursor:"zoomin.cur",restoreCursor:"zoomout.cur",expandDuration:250,restoreDuration:250,marginLeft:15,marginRight:15,marginTop:15,marginBottom:15,zIndexCounter:1001,loadingOpacity:0.75,allowMultipleInstances:true,numberOfImagesToPreload:5,outlineWhileAnimating:2,outlineStartOffset:3,padToMinWidth:false,fullExpandPosition:"bottom right",fullExpandOpacity:1,showCredits:true,creditsHref:"http://highslide.com/",creditsTarget:"_self",enableKeyListener:true,openerTagNames:["a"],dragByHeading:true,minWidth:200,minHeight:200,allowSizeReduction:true,outlineType:"drop-shadow",preloadTheseImages:[],continuePreloading:true,expanders:[],overrides:["allowSizeReduction","useBox","outlineType","outlineWhileAnimating","captionId","captionText","captionEval","captionOverlay","headingId","headingText","headingEval","headingOverlay","creditsPosition","dragByHeading","width","height","wrapperClassName","minWidth","minHeight","maxWidth","maxHeight","pageOrigin","slideshowGroup","easing","easingClose","fadeInOut","src"],overlays:[],idCounter:0,oPos:{x:["leftpanel","left","center","right","rightpanel"],y:["above","top","middle","bottom","below"]},mouse:{},headingOverlay:{},captionOverlay:{},timers:[],pendingOutlines:{},clones:{},onReady:[],uaVersion:/Trident\/4\.0/.test(navigator.userAgent)?8:parseFloat((navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1]),ie:(document.all&&!window.opera),safari:/Safari/.test(navigator.userAgent),geckoMac:/Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent),$:function(a){if(a){return document.getElementById(a)}},push:function(a,b){a[a.length]=b},createElement:function(a,f,e,d,c){var b=document.createElement(a);if(f){hs.extend(b,f)}if(c){hs.setStyles(b,{padding:0,border:"none",margin:0})}if(e){hs.setStyles(b,e)}if(d){d.appendChild(b)}return b},extend:function(b,c){for(var a in c){b[a]=c[a]}return b},setStyles:function(b,c){for(var a in c){if(hs.ieLt9&&a=="opacity"){if(c[a]>0.99){b.style.removeAttribute("filter")}else{b.style.filter="alpha(opacity="+(c[a]*100)+")"}}else{b.style[a]=c[a]}}},animate:function(f,a,d){var c,g,j;if(typeof d!="object"||d===null){var i=arguments;d={duration:i[2],easing:i[3],complete:i[4]}}if(typeof d.duration!="number"){d.duration=250}d.easing=Math[d.easing]||Math.easeInQuad;d.curAnim=hs.extend({},a);for(var b in a){var h=new hs.fx(f,d,b);c=parseFloat(hs.css(f,b))||0;g=parseFloat(a[b]);j=b!="opacity"?"px":"";h.custom(c,g,j)}},css:function(a,c){if(a.style[c]){return a.style[c]}else{if(document.defaultView){return document.defaultView.getComputedStyle(a,null).getPropertyValue(c)}else{if(c=="opacity"){c="filter"}var b=a.currentStyle[c.replace(/\-(\w)/g,function(e,d){return d.toUpperCase()})];if(c=="filter"){b=b.replace(/alpha\(opacity=([0-9]+)\)/,function(e,d){return d/100})}return b===""?1:b}}},getPageSize:function(){var f=document,b=window,e=f.compatMode&&f.compatMode!="BackCompat"?f.documentElement:f.body,g=hs.ie&&(hs.uaVersion<9||typeof pageXOffset=="undefined");var c=g?e.clientWidth:(f.documentElement.clientWidth||self.innerWidth),a=g?e.clientHeight:self.innerHeight;hs.page={width:c,height:a,scrollLeft:g?e.scrollLeft:pageXOffset,scrollTop:g?e.scrollTop:pageYOffset};return hs.page},getPosition:function(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a.offsetParent){a=a.offsetParent;b.x+=a.offsetLeft;b.y+=a.offsetTop;if(a!=document.body&&a!=document.documentElement){b.x-=a.scrollLeft;b.y-=a.scrollTop}}return b},expand:function(b,g,d,c){if(!b){b=hs.createElement("a",null,{display:"none"},hs.container)}if(typeof b.getParams=="function"){return g}try{new hs.Expander(b,g,d);return false}catch(f){return true}},focusTopmost:function(){var c=0,b=-1,a=hs.expanders,e,f;for(var d=0;dc){c=f;b=d}}}if(b==-1){hs.focusKey=-1}else{a[b].focus()}},getParam:function(b,d){b.getParams=b.onclick;var c=b.getParams?b.getParams():null;b.getParams=null;return(c&&typeof c[d]!="undefined")?c[d]:(typeof hs[d]!="undefined"?hs[d]:null)},getSrc:function(b){var c=hs.getParam(b,"src");if(c){return c}return b.href},getNode:function(e){var c=hs.$(e),d=hs.clones[e],b={};if(!c&&!d){return null}if(!d){d=c.cloneNode(true);d.id="";hs.clones[e]=d;return c}else{return d.cloneNode(true)}},discardElement:function(a){if(a){hs.garbageBin.appendChild(a)}hs.garbageBin.innerHTML=""},transit:function(a,d){var b=d||hs.getExpander();d=b;if(hs.upcoming){return false}else{hs.last=b}hs.removeEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler);try{hs.upcoming=a;a.onclick()}catch(c){hs.last=hs.upcoming=null}try{d.close()}catch(c){}return false},previousOrNext:function(a,c){var b=hs.getExpander(a);if(b){return hs.transit(b.getAdjacentAnchor(c),b)}else{return false}},previous:function(a){return hs.previousOrNext(a,-1)},next:function(a){return hs.previousOrNext(a,1)},keyHandler:function(a){if(!a){a=window.event}if(!a.target){a.target=a.srcElement}if(typeof a.target.form!="undefined"){return true}var b=hs.getExpander();var c=null;switch(a.keyCode){case 70:if(b){b.doFullExpand()}return true;case 32:case 34:case 39:case 40:c=1;break;case 8:case 33:case 37:case 38:c=-1;break;case 27:case 13:c=0}if(c!==null){hs.removeEventListener(document,window.opera?"keypress":"keydown",hs.keyHandler);if(!hs.enableKeyListener){return true}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}if(b){if(c==0){b.close()}else{hs.previousOrNext(b.key,c)}return false}}return true},registerOverlay:function(a){hs.push(hs.overlays,hs.extend(a,{hsId:"hsId"+hs.idCounter++}))},getWrapperKey:function(c,b){var e,d=/^highslide-wrapper-([0-9]+)$/;e=c;while(e.parentNode){if(e.id&&d.test(e.id)){return e.id.replace(d,"$1")}e=e.parentNode}if(!b){e=c;while(e.parentNode){if(e.tagName&&hs.isHsAnchor(e)){for(var a=0;a1){return true}if(!d.target){d.target=d.srcElement}var b=d.target;while(b.parentNode&&!(/highslide-(image|move|html|resize)/.test(b.className))){b=b.parentNode}var f=hs.getExpander(b);if(f&&(f.isClosing||!f.isExpanded)){return true}if(f&&d.type=="mousedown"){if(d.target.form){return true}var a=b.className.match(/highslide-(image|move|resize)/);if(a){hs.dragArgs={exp:f,type:a[1],left:f.x.pos,width:f.x.size,top:f.y.pos,height:f.y.size,clickX:d.clientX,clickY:d.clientY};hs.addEventListener(document,"mousemove",hs.dragHandler);if(d.preventDefault){d.preventDefault()}if(/highslide-(image|html)-blur/.test(f.content.className)){f.focus();hs.hasFocused=true}return false}}else{if(d.type=="mouseup"){hs.removeEventListener(document,"mousemove",hs.dragHandler);if(hs.dragArgs){if(hs.styleRestoreCursor&&hs.dragArgs.type=="image"){hs.dragArgs.exp.content.style.cursor=hs.styleRestoreCursor}var c=hs.dragArgs.hasDragged;if(!c&&!hs.hasFocused&&!/(move|resize)/.test(hs.dragArgs.type)){f.close()}else{if(c||(!c&&hs.hasHtmlExpanders)){hs.dragArgs.exp.doShowHide("hidden")}}hs.hasFocused=false;hs.dragArgs=null}else{if(/highslide-image-blur/.test(b.className)){b.style.cursor=hs.styleRestoreCursor}}}}return false},dragHandler:function(c){if(!hs.dragArgs){return true}if(!c){c=window.event}var b=hs.dragArgs,d=b.exp;b.dX=c.clientX-b.clickX;b.dY=c.clientY-b.clickY;var f=Math.sqrt(Math.pow(b.dX,2)+Math.pow(b.dY,2));if(!b.hasDragged){b.hasDragged=(b.type!="image"&&f>0)||(f>(hs.dragSensitivity||5))}if(b.hasDragged&&c.clientX>5&&c.clientY>5){if(b.type=="resize"){d.resize(b)}else{d.moveTo(b.left+b.dX,b.top+b.dY);if(b.type=="image"){d.content.style.cursor="move"}}}return false},wrapperMouseHandler:function(c){try{if(!c){c=window.event}var b=/mouseover/i.test(c.type);if(!c.target){c.target=c.srcElement}if(!c.relatedTarget){c.relatedTarget=b?c.fromElement:c.toElement}var d=hs.getExpander(c.target);if(!d.isExpanded){return}if(!d||!c.relatedTarget||hs.getExpander(c.relatedTarget,true)==d||hs.dragArgs){return}for(var a=0;a=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var a=true;for(var b in this.options.curAnim){if(this.options.curAnim[b]!==true){a=false}}if(a){if(this.options.complete){this.options.complete.call(this.elem)}}return false}else{var e=c-this.startTime;this.state=e/this.options.duration;this.pos=this.options.easing(e,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};hs.extend(hs.fx,{step:{opacity:function(a){hs.setStyles(a.elem,{opacity:a.now})},_default:function(a){try{if(a.elem.style&&a.elem.style[a.prop]!=null){a.elem.style[a.prop]=a.now+a.unit}else{a.elem[a.prop]=a.now}}catch(b){}}}});hs.Outline=function(g,e){this.onLoad=e;this.outlineType=g;var a=hs.uaVersion,f;this.hasAlphaImageLoader=hs.ie&&hs.uaVersion<7;if(!g){if(e){e()}return}hs.init();this.table=hs.createElement("table",{cellSpacing:0},{visibility:"hidden",position:"absolute",borderCollapse:"collapse",width:0},hs.container,true);var b=hs.createElement("tbody",null,null,this.table,1);this.td=[];for(var c=0;c<=8;c++){if(c%3==0){f=hs.createElement("tr",null,{height:"auto"},b,true)}this.td[c]=hs.createElement("td",null,null,f,true);var d=c!=4?{lineHeight:0,fontSize:0}:{position:"relative"};hs.setStyles(this.td[c],d)}this.td[4].className=g+" highslide-outline";this.preloadGraphic()};hs.Outline.prototype={preloadGraphic:function(){var b=hs.graphicsDir+(hs.outlinesDir||"outlines/")+this.outlineType+".png";var a=hs.safari&&hs.uaVersion<525?hs.container:null;this.graphic=hs.createElement("img",null,{position:"absolute",top:"-9999px"},a,true);var c=this;this.graphic.onload=function(){c.onGraphicLoad()};this.graphic.src=b},onGraphicLoad:function(){var d=this.offset=this.graphic.width/4,f=[[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]],c={height:(2*d)+"px",width:(2*d)+"px"};for(var b=0;b<=8;b++){if(f[b]){if(this.hasAlphaImageLoader){var a=(b==1||b==7)?"100%":this.graphic.width+"px";var e=hs.createElement("div",null,{width:"100%",height:"100%",position:"relative",overflow:"hidden"},this.td[b],true);hs.createElement("div",null,{filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+this.graphic.src+"')",position:"absolute",width:a,height:this.graphic.height+"px",left:(f[b][0]*d)+"px",top:(f[b][1]*d)+"px"},e,true)}else{hs.setStyles(this.td[b],{background:"url("+this.graphic.src+") "+(f[b][0]*d)+"px "+(f[b][1]*d)+"px"})}if(window.opera&&(b==3||b==5)){hs.createElement("div",null,c,this.td[b],true)}hs.setStyles(this.td[b],c)}}this.graphic=null;if(hs.pendingOutlines[this.outlineType]){hs.pendingOutlines[this.outlineType].destroy()}hs.pendingOutlines[this.outlineType]=this;if(this.onLoad){this.onLoad()}},setPosition:function(g,e,c,b,f){var d=this.exp,a=d.wrapper.style,e=e||0,g=g||{x:d.x.pos+e,y:d.y.pos+e,w:d.x.get("wsize")-2*e,h:d.y.get("wsize")-2*e};if(c){this.table.style.visibility=(g.h>=4*this.offset)?"visible":"hidden"}hs.setStyles(this.table,{left:(g.x-this.offset)+"px",top:(g.y-this.offset)+"px",width:(g.w+2*this.offset)+"px"});g.w-=2*this.offset;g.h-=2*this.offset;hs.setStyles(this.td[4],{width:g.w>=0?g.w+"px":0,height:g.h>=0?g.h+"px":0});if(this.hasAlphaImageLoader){this.td[3].style.height=this.td[5].style.height=this.td[4].style.height}},destroy:function(a){if(a){this.table.style.visibility="hidden"}else{hs.discardElement(this.table)}}};hs.Dimension=function(b,a){this.exp=b;this.dim=a;this.ucwh=a=="x"?"Width":"Height";this.wh=this.ucwh.toLowerCase();this.uclt=a=="x"?"Left":"Top";this.lt=this.uclt.toLowerCase();this.ucrb=a=="x"?"Right":"Bottom";this.rb=this.ucrb.toLowerCase();this.p1=this.p2=0};hs.Dimension.prototype={get:function(a){switch(a){case"loadingPos":return this.tpos+this.tb+(this.t-hs.loading["offset"+this.ucwh])/2;case"wsize":return this.size+2*this.cb+this.p1+this.p2;case"fitsize":return this.clientSize-this.marginMin-this.marginMax;case"maxsize":return this.get("fitsize")-2*this.cb-this.p1-this.p2;case"opos":return this.pos-(this.exp.outline?this.exp.outline.offset:0);case"osize":return this.get("wsize")+(this.exp.outline?2*this.exp.outline.offset:0);case"imgPad":return this.imgSize?Math.round((this.size-this.imgSize)/2):0}},calcBorders:function(){this.cb=(this.exp.content["offset"+this.ucwh]-this.t)/2;this.marginMax=hs["margin"+this.ucrb]},calcThumb:function(){this.t=this.exp.el[this.wh]?parseInt(this.exp.el[this.wh]):this.exp.el["offset"+this.ucwh];this.tpos=this.exp.tpos[this.dim];this.tb=(this.exp.el["offset"+this.ucwh]-this.t)/2;if(this.tpos==0||this.tpos==-1){this.tpos=(hs.page[this.wh]/2)+hs.page["scroll"+this.uclt]}},calcExpanded:function(){var a=this.exp;this.justify="auto";this.pos=this.tpos-this.cb+this.tb;if(this.maxHeight&&this.dim=="x"){a.maxWidth=Math.min(a.maxWidth||this.full,a.maxHeight*this.full/a.y.full)}this.size=Math.min(this.full,a["max"+this.ucwh]||this.full);this.minSize=a.allowSizeReduction?Math.min(a["min"+this.ucwh],this.full):this.full;if(a.isImage&&a.useBox){this.size=a[this.wh];this.imgSize=this.full}if(this.dim=="x"&&hs.padToMinWidth){this.minSize=a.minWidth}this.marginMin=hs["margin"+this.uclt];this.scroll=hs.page["scroll"+this.uclt];this.clientSize=hs.page[this.wh]},setSize:function(a){var b=this.exp;if(b.isImage&&(b.useBox||hs.padToMinWidth)){this.imgSize=a;this.size=Math.max(this.size,this.imgSize);b.content.style[this.lt]=this.get("imgPad")+"px"}else{this.size=a}b.content.style[this.wh]=a+"px";b.wrapper.style[this.wh]=this.get("wsize")+"px";if(b.outline){b.outline.setPosition()}if(this.dim=="x"&&b.overlayBox){b.sizeOverlayBox(true)}},setPos:function(a){this.pos=a;this.exp.wrapper.style[this.lt]=a+"px";if(this.exp.outline){this.exp.outline.setPosition()}}};hs.Expander=function(k,f,b,l){if(document.readyState&&hs.ie&&!hs.isReady){hs.addEventListener(document,"ready",function(){new hs.Expander(k,f,b,l)});return}this.a=k;this.custom=b;this.contentType=l||"image";this.isImage=!this.isHtml;hs.continuePreloading=false;this.overlays=[];hs.init();var m=this.key=hs.expanders.length;for(var g=0;g(this.x.imgSize||this.x.size)){this.createFullExpand();if(this.overlays.length==1){this.sizeOverlayBox()}}}this.show()}catch(c){this.error(c)}},justify:function(f,b){var g,h=f.target,e=f==this.x?"x":"y";var d=false;var a=f.exp.allowSizeReduction;f.pos=Math.round(f.pos-((f.get("wsize")-f.t)/2));if(f.posf.scroll+f.clientSize-f.marginMax){if(!b&&d&&a){f.size=Math.min(f.size,f.get(e=="y"?"fitsize":"maxsize"))}else{if(f.get("wsize")c){d=b*c;if(dthis.minHeight&&a.size>this.minWidth&&d.get("wsize")>d.get("fitsize")){d.size-=10;if(b){a.size=d.size*b}this.sizeOverlayBox(0,1);c=true}}return c},show:function(){var a=this.x,b=this.y;this.doShowHide("hidden");this.changeSize(1,{wrapper:{width:a.get("wsize"),height:b.get("wsize"),left:a.pos,top:b.pos},content:{left:a.p1+a.get("imgPad"),top:b.p1+b.get("imgPad"),width:a.imgSize||a.size,height:b.imgSize||b.size}},hs.expandDuration)},changeSize:function(b,h,c){if(this.outline&&!this.outlineWhileAnimating){if(b){this.outline.setPosition()}else{this.outline.destroy()}}if(!b){this.destroyOverlays()}var e=this,a=e.x,g=e.y,f=this.easing;if(!b){f=this.easingClose||f}var d=b?function(){if(e.outline){e.outline.table.style.visibility="visible"}setTimeout(function(){e.afterExpand()},50)}:function(){e.afterClose()};if(b){hs.setStyles(this.wrapper,{width:a.t+"px",height:g.t+"px"})}if(this.fadeInOut){hs.setStyles(this.wrapper,{opacity:b?0:1});hs.extend(h.wrapper,{opacity:b})}hs.animate(this.wrapper,h.wrapper,{duration:c,easing:f,step:function(k,i){if(e.outline&&e.outlineWhileAnimating&&i.prop=="top"){var j=b?i.pos:1-i.pos;var l={w:a.t+(a.get("wsize")-a.t)*j,h:g.t+(g.get("wsize")-g.t)*j,x:a.tpos+(a.pos-a.tpos)*j,y:g.tpos+(g.pos-g.tpos)*j};e.outline.setPosition(l,0,1)}}});hs.animate(this.content,h.content,c,f,d);if(b){this.wrapper.style.visibility="visible";this.content.style.visibility="visible";this.a.className+=" highslide-active-anchor"}},afterExpand:function(){this.isExpanded=true;this.focus();if(hs.upcoming&&hs.upcoming==this.a){hs.upcoming=null}this.prepareNextOutline();var c=hs.page,b=hs.mouse.x+c.scrollLeft,a=hs.mouse.y+c.scrollTop;this.mouseIsOver=this.x.posthis.x.get("opos")+this.x.get("osize"));var g=(k.y+k.hthis.y.get("opos")+this.y.get("osize"));var d=hs.getWrapperKey(e[f]);if(!j&&!g&&d!=this.key){if(!h){e[f].setAttribute("hidden-by","["+this.key+"]");e[f].origProp=e[f].style[a];e[f].style[a]="hidden"}else{if(h.indexOf("["+this.key+"]")==-1){e[f].setAttribute("hidden-by",h+"["+this.key+"]")}}}else{if((h=="["+this.key+"]"||hs.focusKey==d)&&d!=this.key){e[f].setAttribute("hidden-by","");e[f].style[a]=e[f].origProp||""}else{if(h&&h.indexOf("["+this.key+"]")>-1){e[f].setAttribute("hidden-by",h.replace("["+this.key+"]",""))}}}}}}}},focus:function(){this.wrapper.style.zIndex=hs.zIndexCounter+=2;for(var a=0;a
'; + for (x in this.points) { + var point = this.points[x]; + var colour = point.point.pointAttr[''].fill; + str += '' + point.series.name + ': € ' + Highcharts.numberFormat(point.y, 2) + '
'; + } + //console.log(); + return str; + return '' + this.series.name + ' on ' + Highcharts.dateFormat("%e %B", this.x) + ':
€ ' + Highcharts.numberFormat(this.y, 2); + } + }, + plotOptions: { + line: { + shadow: true + }, + series: { + cursor: 'pointer', + negativeColor: '#FF0000', + threshold: 0, + lineWidth: 1, + marker: { + radius: 2 + }, + point: { + events: { + click: function (e) { + hs.htmlExpand(null, { + src: 'chart/home/info/' + this.series.name + '/' + Highcharts.dateFormat("%d/%m/%Y", this.x), + pageOrigin: { + x: e.pageX, + y: e.pageY + }, + objectType: 'ajax', + headingText: this.series.name, + width: 250 + } + ) + ; + } + } + } + } + }, + credits: { + enabled: false + } }; - - - // draw it! - drawChart('#' + holderID, URL, 'LineChart', opt); + $('#chart').highcharts(options); }); - //var URL = 'chart/home'; - //drawChart('#chart',URL,opt); -} + /** + * Get chart data for categories chart: + */ + $.getJSON('chart/home/categories').success(function (data) { + $('#categories').highcharts({ + chart: { + type: 'column' + }, + title: { + text: 'Expenses for each categorie' + }, + credits: { + enabled: false + }, + xAxis: { + type: 'category', + labels: { + rotation: -45, + style: { + fontSize: '12px', + fontFamily: 'Verdana, sans-serif' + } + } + }, + yAxis: { + min: 0, + title: { + text: 'Expense (€)' + } + }, + legend: { + enabled: false + }, + tooltip: { + pointFormat: 'Total expense: € {point.y:.2f}', + }, + plotOptions: { + column: { + cursor: 'pointer' + } + }, + series: [ + { + name: 'Population', + data: data, -function drawExtraCharts() { + events: { + click: function (e) { + alert('klik!'); + } + }, + dataLabels: { + enabled: false + } + } + ] + }); + }); - var opt = { - legend: { - position: 'none' - }, - chartArea: { - width: 300, - height: 300 - }, - }; - - drawChart('#budgetChart', 'chart/home/budgets', 'PieChart', opt); - drawChart('#categoryChart', 'chart/home/categories','PieChart', opt); - drawChart('#beneficiaryChart', 'chart/home/beneficiaries','PieChart', opt); -} \ No newline at end of file +}); \ No newline at end of file diff --git a/public/assets/javascript/index.new.js b/public/assets/javascript/index.new.js deleted file mode 100644 index e3ab37250b..0000000000 --- a/public/assets/javascript/index.new.js +++ /dev/null @@ -1,119 +0,0 @@ -$(function () { - - - var charts = new Array; - /** - * get data from controller for home charts: - */ - $.each($('.homeChart'), function (i, v) { - var obj = $(v); - $.getJSON('chart/home/account/' + obj.data('id')).success(function (data) { - var options = { - chart: { - renderTo: obj.attr('id'), - type: 'line' - }, - title: { - text: obj.data('title') - }, - yAxis: { - title: { - text: 'Balance (€)' - }, - formatter: function () { - return '$' + Highcharts.numberFormat(this.y, 0); - } - }, - - xAxis: { - floor: 0, - type: 'datetime', - dateTimeLabelFormats: { - month: '%e %b', - year: '%b' - }, - title: { - text: 'Date' - } - }, - tooltip: { - valuePrefix: '€ ', - formatter: function () { - return '€ ' + Highcharts.numberFormat(this.y, 2); - } - }, - plotOptions: { - - line: { - negativeColor: '#FF0000', - threshold: 0, - lineWidth: 1, - marker: { - radius: 2 - } - } - }, - series: data - }; - - charts[i] = new Highcharts.Chart(options); - - }); - }); - - // draw bene / bud / cat: - var options = { - chart: { - renderTo: 'nothing', - type: 'pie' - }, - title: { - text: 'No title yet' - }, - - xAxis: { - type: 'datetime' - }, - tooltip: { - valuePrefix: '€ ' - }, - plotOptions: { - pie: { - allowPointSelect: false, - dataLabels: { - enabled: false - }, - showInLegend: false - } - }, - series: [] - }; - // now get some data: - $.getJSON('chart/home/beneficiaries').success(function (data) { - var opt = options; - opt.series = data; - opt.chart.renderTo = 'beneficiaryChart'; - opt.title.text = 'Beneficiaries'; - charts.push(new Highcharts.Chart(opt)); - }); - - // now get some more data! - $.getJSON('chart/home/categories').success(function (data) { - var opt = options; - opt.series = data; - opt.chart.renderTo = 'categoryChart'; - opt.title.text = 'Categories'; - charts.push(new Highcharts.Chart(opt)); - }); - - // now get some even more data! - $.getJSON('chart/home/budgets').success(function (data) { - var opt = options; - opt.series = data; - opt.chart.renderTo = 'budgetChart'; - opt.title.text = 'Budgets'; - charts.push(new Highcharts.Chart(opt)); - }); - - -}); \ No newline at end of file