From 538c34ecd49f162544806c64e5fa13e928403c03 Mon Sep 17 00:00:00 2001 From: "alextselegidis@gmail.com" Date: Thu, 10 Oct 2013 16:50:33 +0000 Subject: [PATCH] * Added jScrollPane on some of the admin pages. * Selected backend menu item is now active. * The logged in user can see his name on the footer. * Completed previleges checks for secretaries. --- src/application/controllers/backend.php | 22 ++++ src/application/models/roles_model.php | 8 +- src/application/models/user_model.php | 13 ++ src/application/views/appointments/book.php | 4 +- src/application/views/backend/calendar.php | 5 +- src/application/views/backend/customers.php | 8 +- src/application/views/backend/footer.php | 4 + src/application/views/backend/header.php | 25 +++- src/application/views/backend/services.php | 8 +- src/application/views/backend/settings.php | 10 +- src/application/views/backend/users.php | 24 ++-- src/assets/css/backend.css | 36 +++++- src/assets/css/frontend.css | 3 +- .../css/libs/jquery/jquery.jscrollpane.css | 120 ++++++++++++++++++ src/assets/js/backend_calendar.js | 25 +++- src/assets/js/backend_customers.js | 8 ++ src/assets/js/backend_services.js | 12 +- src/assets/js/backend_users.js | 15 ++- src/assets/js/backend_users_admins.js | 4 +- src/assets/js/backend_users_providers.js | 5 +- src/assets/js/backend_users_secretaries.js | 4 +- .../js/libs/jquery/jquery.jscrollpane.min.js | 8 ++ .../js/libs/jquery/jquery.mousewheel.js | 117 +++++++++++++++++ 23 files changed, 437 insertions(+), 51 deletions(-) create mode 100644 src/assets/css/libs/jquery/jquery.jscrollpane.css create mode 100644 src/assets/js/libs/jquery/jquery.jscrollpane.min.js create mode 100644 src/assets/js/libs/jquery/jquery.mousewheel.js diff --git a/src/application/controllers/backend.php b/src/application/controllers/backend.php index 8994b34f..6cc1ca3f 100644 --- a/src/application/controllers/backend.php +++ b/src/application/controllers/backend.php @@ -27,8 +27,12 @@ class Backend extends CI_Controller { $this->load->model('customers_model'); $this->load->model('settings_model'); $this->load->model('roles_model'); + $this->load->model('user_model'); + $this->load->model('secretaries_model'); $view['base_url'] = $this->config->item('base_url'); + $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); + $view['active_menu'] = PRIV_APPOINTMENTS; $view['book_advance_timeout'] = $this->settings_model->get_setting('book_advance_timeout'); $view['company_name'] = $this->settings_model->get_setting('company_name'); $view['available_providers'] = $this->providers_model->get_available_providers(); @@ -36,6 +40,13 @@ class Backend extends CI_Controller { $view['customers'] = $this->customers_model->get_batch(); $this->setUserData($view); + if ($this->session->userdata('role_slug') == DB_SLUG_SECRETARY) { + $secretary = $this->secretaries_model->get_row($this->session->userdata('user_id')); + $view['secretary_providers'] = $secretary['providers']; + } else { + $view['secretary_providers'] = array(); + } + if ($appointment_hash != '') { $results = $this->appointments_model->get_batch(array('hash' => $appointment_hash)); $appointment = $results[0]; @@ -63,8 +74,11 @@ class Backend extends CI_Controller { $this->load->model('customers_model'); $this->load->model('services_model'); $this->load->model('settings_model'); + $this->load->model('user_model'); $view['base_url'] = $this->config->item('base_url'); + $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); + $view['active_menu'] = PRIV_CUSTOMERS; $view['company_name'] = $this->settings_model->get_setting('company_name'); $view['customers'] = $this->customers_model->get_batch(); $view['available_providers'] = $this->providers_model->get_available_providers(); @@ -92,8 +106,11 @@ class Backend extends CI_Controller { $this->load->model('customers_model'); $this->load->model('services_model'); $this->load->model('settings_model'); + $this->load->model('user_model'); $view['base_url'] = $this->config->item('base_url'); + $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); + $view['active_menu'] = PRIV_SERVICES; $view['company_name'] = $this->settings_model->get_setting('company_name'); $view['services'] = $this->services_model->get_batch(); $view['categories'] = $this->services_model->get_all_categories(); @@ -120,8 +137,11 @@ class Backend extends CI_Controller { $this->load->model('admins_model'); $this->load->model('services_model'); $this->load->model('settings_model'); + $this->load->model('user_model'); $view['base_url'] = $this->config->item('base_url'); + $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); + $view['active_menu'] = PRIV_USERS; $view['company_name'] = $this->settings_model->get_setting('company_name'); $view['admins'] = $this->admins_model->get_batch(); $view['providers'] = $this->providers_model->get_batch(); @@ -154,6 +174,8 @@ class Backend extends CI_Controller { $user_id = $this->session->userdata('user_id'); $view['base_url'] = $this->config->item('base_url'); + $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); + $view['active_menu'] = PRIV_SYSTEM_SETTINGS; $view['company_name'] = $this->settings_model->get_setting('company_name'); $view['role_slug'] = $this->session->userdata('role_slug'); $view['system_settings'] = $this->settings_model->get_settings(); diff --git a/src/application/models/roles_model.php b/src/application/models/roles_model.php index 955522ef..6555145c 100644 --- a/src/application/models/roles_model.php +++ b/src/application/models/roles_model.php @@ -39,10 +39,10 @@ class Roles_Model extends CI_Model { $privileges_number = $value; $value = array( - 'view' => false, - 'add' => false, - 'edit' => false, - 'delete' => false + 'view' => FALSE, + 'add' => FALSE, + 'edit' => FALSE, + 'delete' => FALSE ); if ($privileges_number > 0) { diff --git a/src/application/models/user_model.php b/src/application/models/user_model.php index 53a2173e..ed85d31d 100644 --- a/src/application/models/user_model.php +++ b/src/application/models/user_model.php @@ -89,6 +89,19 @@ class User_Model extends CI_Model { return ($user_data) ? $user_data : NULL; } + + /** + * Get the given user's display name (first + last name). + * + * @param numeric $user_id The given user record id. + * @return string Returns the user display name. + */ + public function get_user_display_name($user_id) { + if (!is_numeric($user_id)) + throw new Exception ('Invalid argument given ($user_id = "' . $user_id . '").'); + $user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array(); + return $user['first_name'] . ' ' . $user['last_name']; + } } /* End of file user_model.php */ diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index 2b94fde3..8ef2ea61 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -272,8 +272,8 @@
- - + + diff --git a/src/application/views/backend/calendar.php b/src/application/views/backend/calendar.php index f92309f9..0267ad0e 100644 --- a/src/application/views/backend/calendar.php +++ b/src/application/views/backend/calendar.php @@ -18,6 +18,7 @@ 'bookAdvanceTimeout' : , 'editAppointment' : , 'customers' : , + 'secretaryProviders' : , 'user' : { 'id' : , 'email' : , @@ -142,9 +143,9 @@
- +
- +
diff --git a/src/application/views/backend/customers.php b/src/application/views/backend/customers.php index d7011816..32da9076 100644 --- a/src/application/views/backend/customers.php +++ b/src/application/views/backend/customers.php @@ -45,8 +45,8 @@
- @@ -79,8 +79,8 @@

Details

- - + + diff --git a/src/application/views/backend/footer.php b/src/application/views/backend/footer.php index 168fbf3a..82641920 100644 --- a/src/application/views/backend/footer.php +++ b/src/application/views/backend/footer.php @@ -5,6 +5,10 @@ Alex Tselegidis | Licensed Under GPLv3
+ +
\ No newline at end of file diff --git a/src/application/views/backend/header.php b/src/application/views/backend/header.php index 6d8ccf78..55c1d222 100644 --- a/src/application/views/backend/header.php +++ b/src/application/views/backend/header.php @@ -35,6 +35,10 @@ rel="stylesheet" type="text/css" href="assets/css/general.css"> + assets/js/backend.js"> + + @@ -74,28 +84,32 @@ - + + Calendar - + + Customers - + + Services - + + Users @@ -103,7 +117,8 @@ // ------------------------------------------------------ ?> - + + Settings diff --git a/src/application/views/backend/services.php b/src/application/views/backend/services.php index 11111519..586d01e1 100644 --- a/src/application/views/backend/services.php +++ b/src/application/views/backend/services.php @@ -54,8 +54,8 @@
-

'; return html; }; @@ -603,11 +607,13 @@ CategoriesHelper.prototype.filter = function(key, selectId, display) { BackendServices.helper.filterResults = response; + $('#filter-categories .results').data('jsp').destroy(); $('#filter-categories .results').html(''); $.each(response, function(index, category) { var html = BackendServices.helper.getFilterHtml(category); $('#filter-categories .results').append(html); }); + $('#filter-categories .results').jScrollPane(); if (response.length == 0) { $('#filter-categories .results').html('No records found...'); @@ -730,7 +736,7 @@ CategoriesHelper.prototype.getFilterHtml = function(category) { var html = '
' + '' + category.name + '' + - '
'; + '

'; return html; }; diff --git a/src/assets/js/backend_users.js b/src/assets/js/backend_users.js index fb618719..27a51fd8 100644 --- a/src/assets/js/backend_users.js +++ b/src/assets/js/backend_users.js @@ -30,6 +30,11 @@ var BackendUsers = { initialize: function(defaultEventHandlers) { if (defaultEventHandlers == undefined) defaultEventHandlers = true; + // Initialize jScrollPane Scrollbars + $('#filter-admins .results').jScrollPane(); + $('#filter-providers .results').jScrollPane(); + $('#filter-secretaries .results').jScrollPane(); + // Instanciate default helper object (admin). BackendUsers.helper = new AdminsHelper(); BackendUsers.helper.resetForm(); @@ -44,12 +49,14 @@ var BackendUsers = { + service.name + ''; $('#provider-services').append(html); }); - + $('#provider-services').jScrollPane(); + $.each(GlobalVariables.providers, function(index, provider) { var html = ''; $('#secretary-providers').append(html); }); + $('#secretary-providers').jScrollPane(); // Bind event handlers. if (defaultEventHandlers) BackendUsers.bindEventHandlers(); @@ -75,6 +82,8 @@ var BackendUsers = { BackendUsers.helper = new AdminsHelper(); } else if ($(this).hasClass('providers-tab')) { // display providers tab $('#providers').show(); + $('#provider-services').data('jsp').destroy(); + $('#provider-services').jScrollPane(); BackendUsers.helper = new ProvidersHelper(); } else if ($(this).hasClass('secretaries-tab')) { // display secretaries tab $('#secretaries').show(); @@ -91,7 +100,8 @@ var BackendUsers = { if (!GeneralFunctions.handleAjaxExceptions(response)) return; GlobalVariables.providers = response; - + + $('#secretary-providers').data('jsp').destroy(); $('#secretary-providers').html(''); $.each(GlobalVariables.providers, function(index, provider) { var html = '

'; return html; }; diff --git a/src/assets/js/backend_users_providers.js b/src/assets/js/backend_users_providers.js index 331c1feb..7367065f 100644 --- a/src/assets/js/backend_users_providers.js +++ b/src/assets/js/backend_users_providers.js @@ -390,11 +390,14 @@ ProvidersHelper.prototype.filter = function(key, selectId, display) { BackendUsers.helper.filterResults = response; + + $('#filter-providers .results').data('jsp').destroy; $('#filter-providers .results').html(''); $.each(response, function(index, provider) { var html = ProvidersHelper.prototype.getFilterHtml(provider); $('#filter-providers .results').append(html); }); + $('#filter-providers .results').jScrollPane(); if (response.length == 0) { $('#filter-providers .results').html('No results found ...') @@ -417,7 +420,7 @@ ProvidersHelper.prototype.getFilterHtml = function(provider) { '
' + '' + provider.first_name + ' ' + provider.last_name + '
' + provider.email + ', ' + provider.mobile_number + ', ' + provider.phone_number + '
' + - '
'; + '

'; return html; }; diff --git a/src/assets/js/backend_users_secretaries.js b/src/assets/js/backend_users_secretaries.js index c742b42e..272146e3 100644 --- a/src/assets/js/backend_users_secretaries.js +++ b/src/assets/js/backend_users_secretaries.js @@ -345,11 +345,13 @@ SecretariesHelper.prototype.filter = function(key, selectId, display) { BackendUsers.helper.filterResults = response; + $('#filter-secretaries .results').data('jsp').destroy(); $('#filter-secretaries .results').html(''); $.each(response, function(index, secretary) { var html = SecretariesHelper.prototype.getFilterHtml(secretary); $('#filter-secretaries .results').append(html); }); + $('#filter-secretaries .results').jScrollPane(); if (response.length == 0) { $('#filter-secretaries .results').html('No results found ...') @@ -372,7 +374,7 @@ SecretariesHelper.prototype.getFilterHtml = function(secretary) { '
' + '' + secretary.first_name + ' ' + secretary.last_name + '
' + secretary.email + ', ' + secretary.mobile_number + ', ' + secretary.phone_number + '
' + - '
'; + '

'; return html; }; diff --git a/src/assets/js/libs/jquery/jquery.jscrollpane.min.js b/src/assets/js/libs/jquery/jquery.jscrollpane.min.js new file mode 100644 index 00000000..138e1f6c --- /dev/null +++ b/src/assets/js/libs/jquery/jquery.jscrollpane.min.js @@ -0,0 +1,8 @@ +/*! + * jScrollPane - v2.0.17 - 2013-08-17 + * http://jscrollpane.kelvinluck.com/ + * + * Copyright (c) 2013 Kelvin Luck + * Dual licensed under the MIT or GPL licenses. + */ +!function(a,b,c){a.fn.jScrollPane=function(d){function e(d,e){function f(b){var e,h,j,l,m,n,q=!1,r=!1;if(P=b,Q===c)m=d.scrollTop(),n=d.scrollLeft(),d.css({overflow:"hidden",padding:0}),R=d.innerWidth()+tb,S=d.innerHeight(),d.width(R),Q=a('
').css("padding",sb).append(d.children()),T=a('
').css({width:R+"px",height:S+"px"}).append(Q).appendTo(d);else{if(d.css("width",""),q=P.stickToBottom&&C(),r=P.stickToRight&&D(),l=d.innerWidth()+tb!=R||d.outerHeight()!=S,l&&(R=d.innerWidth()+tb,S=d.innerHeight(),T.css({width:R+"px",height:S+"px"})),!l&&ub==U&&Q.outerHeight()==V)return d.width(R),void 0;ub=U,Q.css("width",""),d.width(R),T.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Q.css("overflow","auto"),U=b.contentWidth?b.contentWidth:Q[0].scrollWidth,V=Q[0].scrollHeight,Q.css("overflow",""),W=U/R,X=V/S,Y=X>1,Z=W>1,Z||Y?(d.addClass("jspScrollable"),e=P.maintainPosition&&(ab||db),e&&(h=A(),j=B()),g(),i(),k(),e&&(y(r?U-R:h,!1),x(q?V-S:j,!1)),H(),E(),N(),P.enableKeyboardNavigation&&J(),P.clickOnTrack&&o(),L(),P.hijackInternalLinks&&M()):(d.removeClass("jspScrollable"),Q.css({top:0,left:0,width:T.width()-tb}),F(),I(),K(),p()),P.autoReinitialise&&!rb?rb=setInterval(function(){f(P)},P.autoReinitialiseDelay):!P.autoReinitialise&&rb&&clearInterval(rb),m&&d.scrollTop(0)&&x(m,!1),n&&d.scrollLeft(0)&&y(n,!1),d.trigger("jsp-initialised",[Z||Y])}function g(){Y&&(T.append(a('
').append(a('
'),a('
').append(a('
').append(a('
'),a('
'))),a('
'))),eb=T.find(">.jspVerticalBar"),fb=eb.find(">.jspTrack"),$=fb.find(">.jspDrag"),P.showArrows&&(jb=a('').bind("mousedown.jsp",m(0,-1)).bind("click.jsp",G),kb=a('').bind("mousedown.jsp",m(0,1)).bind("click.jsp",G),P.arrowScrollOnHover&&(jb.bind("mouseover.jsp",m(0,-1,jb)),kb.bind("mouseover.jsp",m(0,1,kb))),l(fb,P.verticalArrowPositions,jb,kb)),hb=S,T.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){hb-=a(this).outerHeight()}),$.hover(function(){$.addClass("jspHover")},function(){$.removeClass("jspHover")}).bind("mousedown.jsp",function(b){a("html").bind("dragstart.jsp selectstart.jsp",G),$.addClass("jspActive");var c=b.pageY-$.position().top;return a("html").bind("mousemove.jsp",function(a){r(a.pageY-c,!1)}).bind("mouseup.jsp mouseleave.jsp",q),!1}),h())}function h(){fb.height(hb+"px"),ab=0,gb=P.verticalGutter+fb.outerWidth(),Q.width(R-gb-tb);try{0===eb.position().left&&Q.css("margin-left",gb+"px")}catch(a){}}function i(){Z&&(T.append(a('
').append(a('
'),a('
').append(a('
').append(a('
'),a('
'))),a('
'))),lb=T.find(">.jspHorizontalBar"),mb=lb.find(">.jspTrack"),bb=mb.find(">.jspDrag"),P.showArrows&&(pb=a('').bind("mousedown.jsp",m(-1,0)).bind("click.jsp",G),qb=a('').bind("mousedown.jsp",m(1,0)).bind("click.jsp",G),P.arrowScrollOnHover&&(pb.bind("mouseover.jsp",m(-1,0,pb)),qb.bind("mouseover.jsp",m(1,0,qb))),l(mb,P.horizontalArrowPositions,pb,qb)),bb.hover(function(){bb.addClass("jspHover")},function(){bb.removeClass("jspHover")}).bind("mousedown.jsp",function(b){a("html").bind("dragstart.jsp selectstart.jsp",G),bb.addClass("jspActive");var c=b.pageX-bb.position().left;return a("html").bind("mousemove.jsp",function(a){t(a.pageX-c,!1)}).bind("mouseup.jsp mouseleave.jsp",q),!1}),nb=T.innerWidth(),j())}function j(){T.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){nb-=a(this).outerWidth()}),mb.width(nb+"px"),db=0}function k(){if(Z&&Y){var b=mb.outerHeight(),c=fb.outerWidth();hb-=b,a(lb).find(">.jspCap:visible,>.jspArrow").each(function(){nb+=a(this).outerWidth()}),nb-=c,S-=c,R-=b,mb.parent().append(a('
').css("width",b+"px")),h(),j()}Z&&Q.width(T.outerWidth()-tb+"px"),V=Q.outerHeight(),X=V/S,Z&&(ob=Math.ceil(1/W*nb),ob>P.horizontalDragMaxWidth?ob=P.horizontalDragMaxWidth:obP.verticalDragMaxHeight?ib=P.verticalDragMaxHeight:ibg)ab-k>c?vb.scrollByY(-f):r(c);else{if(!(g>0))return j(),void 0;c>ab+k?vb.scrollByY(f):r(c)}d=setTimeout(i,h?P.initialDelay:P.trackClickRepeatFreq),h=!1},j=function(){d&&clearTimeout(d),d=null,a(document).unbind("mouseup.jsp",j)};return i(),a(document).bind("mouseup.jsp",j),!1}}),Z&&mb.bind("mousedown.jsp",function(b){if(b.originalTarget===c||b.originalTarget==b.currentTarget){var d,e=a(this),f=e.offset(),g=b.pageX-f.left-db,h=!0,i=function(){var a=e.offset(),c=b.pageX-a.left-ob/2,f=R*P.scrollPagePercent,k=cb*f/(U-R);if(0>g)db-k>c?vb.scrollByX(-f):t(c);else{if(!(g>0))return j(),void 0;c>db+k?vb.scrollByX(f):t(c)}d=setTimeout(i,h?P.initialDelay:P.trackClickRepeatFreq),h=!1},j=function(){d&&clearTimeout(d),d=null,a(document).unbind("mouseup.jsp",j)};return i(),a(document).bind("mouseup.jsp",j),!1}})}function p(){mb&&mb.unbind("mousedown.jsp"),fb&&fb.unbind("mousedown.jsp")}function q(){a("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp"),$&&$.removeClass("jspActive"),bb&&bb.removeClass("jspActive")}function r(a,b){Y&&(0>a?a=0:a>_&&(a=_),b===c&&(b=P.animateScroll),b?vb.animate($,"top",a,s):($.css("top",a),s(a)))}function s(a){a===c&&(a=$.position().top),T.scrollTop(0),ab=a;var b=0===ab,e=ab==_,f=a/_,g=-f*(V-S);(wb!=b||yb!=e)&&(wb=b,yb=e,d.trigger("jsp-arrow-change",[wb,yb,xb,zb])),v(b,e),Q.css("top",g),d.trigger("jsp-scroll-y",[-g,b,e]).trigger("scroll")}function t(a,b){Z&&(0>a?a=0:a>cb&&(a=cb),b===c&&(b=P.animateScroll),b?vb.animate(bb,"left",a,u):(bb.css("left",a),u(a)))}function u(a){a===c&&(a=bb.position().left),T.scrollTop(0),db=a;var b=0===db,e=db==cb,f=a/cb,g=-f*(U-R);(xb!=b||zb!=e)&&(xb=b,zb=e,d.trigger("jsp-arrow-change",[wb,yb,xb,zb])),w(b,e),Q.css("left",g),d.trigger("jsp-scroll-x",[-g,b,e]).trigger("scroll")}function v(a,b){P.showArrows&&(jb[a?"addClass":"removeClass"]("jspDisabled"),kb[b?"addClass":"removeClass"]("jspDisabled"))}function w(a,b){P.showArrows&&(pb[a?"addClass":"removeClass"]("jspDisabled"),qb[b?"addClass":"removeClass"]("jspDisabled"))}function x(a,b){var c=a/(V-S);r(c*_,b)}function y(a,b){var c=a/(U-R);t(c*cb,b)}function z(b,c,d){var e,f,g,h,i,j,k,l,m,n=0,o=0;try{e=a(b)}catch(p){return}for(f=e.outerHeight(),g=e.outerWidth(),T.scrollTop(0),T.scrollLeft(0);!e.is(".jspPane");)if(n+=e.position().top,o+=e.position().left,e=e.offsetParent(),/^body|html$/i.test(e[0].nodeName))return;h=B(),j=h+S,h>n||c?l=n-P.verticalGutter:n+f>j&&(l=n-S+f+P.verticalGutter),isNaN(l)||x(l,d),i=A(),k=i+R,i>o||c?m=o-P.horizontalGutter:o+g>k&&(m=o-R+g+P.horizontalGutter),isNaN(m)||y(m,d)}function A(){return-Q.position().left}function B(){return-Q.position().top}function C(){var a=V-S;return a>20&&a-B()<10}function D(){var a=U-R;return a>20&&a-A()<10}function E(){T.unbind(Bb).bind(Bb,function(a,b,c,d){var e=db,f=ab;return vb.scrollBy(c*P.mouseWheelSpeed,-d*P.mouseWheelSpeed,!1),e==db&&f==ab})}function F(){T.unbind(Bb)}function G(){return!1}function H(){Q.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(a){z(a.target,!1)})}function I(){Q.find(":input,a").unbind("focus.jsp")}function J(){function b(){var a=db,b=ab;switch(c){case 40:vb.scrollByY(P.keyboardSpeed,!1);break;case 38:vb.scrollByY(-P.keyboardSpeed,!1);break;case 34:case 32:vb.scrollByY(S*P.scrollPagePercent,!1);break;case 33:vb.scrollByY(-S*P.scrollPagePercent,!1);break;case 39:vb.scrollByX(P.keyboardSpeed,!1);break;case 37:vb.scrollByX(-P.keyboardSpeed,!1)}return e=a!=db||b!=ab}var c,e,f=[];Z&&f.push(lb[0]),Y&&f.push(eb[0]),Q.focus(function(){d.focus()}),d.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(d){if(d.target===this||f.length&&a(d.target).closest(f).length){var g=db,h=ab;switch(d.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:c=d.keyCode,b();break;case 35:x(V-S),c=null;break;case 36:x(0),c=null}return e=d.keyCode==c&&g!=db||h!=ab,!e}}).bind("keypress.jsp",function(a){return a.keyCode==c&&b(),!e}),P.hideFocus?(d.css("outline","none"),"hideFocus"in T[0]&&d.attr("hideFocus",!0)):(d.css("outline",""),"hideFocus"in T[0]&&d.attr("hideFocus",!1))}function K(){d.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function L(){if(location.hash&&location.hash.length>1){var b,c,d=escape(location.hash.substr(1));try{b=a("#"+d+', a[name="'+d+'"]')}catch(e){return}b.length&&Q.find(d)&&(0===T.scrollTop()?c=setInterval(function(){T.scrollTop()>0&&(z(b,!0),a(document).scrollTop(T.position().top),clearInterval(c))},50):(z(b,!0),a(document).scrollTop(T.position().top)))}}function M(){a(document.body).data("jspHijack")||(a(document.body).data("jspHijack",!0),a(document.body).delegate("a[href*=#]","click",function(c){var d,e,f,g,h,i,j=this.href.substr(0,this.href.indexOf("#")),k=location.href;if(-1!==location.href.indexOf("#")&&(k=location.href.substr(0,location.href.indexOf("#"))),j===k){d=escape(this.href.substr(this.href.indexOf("#")+1));try{e=a("#"+d+', a[name="'+d+'"]')}catch(l){return}e.length&&(f=e.closest(".jspScrollable"),g=f.data("jsp"),g.scrollToElement(e,!0),f[0].scrollIntoView&&(h=a(b).scrollTop(),i=e.offset().top,(h>i||i>h+a(b).height())&&f[0].scrollIntoView()),c.preventDefault())}}))}function N(){var a,b,c,d,e,f=!1;T.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(g){var h=g.originalEvent.touches[0];a=A(),b=B(),c=h.pageX,d=h.pageY,e=!1,f=!0}).bind("touchmove.jsp",function(g){if(f){var h=g.originalEvent.touches[0],i=db,j=ab;return vb.scrollTo(a+c-h.pageX,b+d-h.pageY),e=e||Math.abs(c-h.pageX)>5||Math.abs(d-h.pageY)>5,i==db&&j==ab}}).bind("touchend.jsp",function(){f=!1}).bind("click.jsp-touchclick",function(){return e?(e=!1,!1):void 0})}function O(){var a=B(),b=A();d.removeClass("jspScrollable").unbind(".jsp"),d.replaceWith(Ab.append(Q.children())),Ab.scrollTop(a),Ab.scrollLeft(b),rb&&clearInterval(rb)}var P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb=this,wb=!0,xb=!0,yb=!1,zb=!1,Ab=d.clone(!1,!1).empty(),Bb=a.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";"border-box"===d.css("box-sizing")?(sb=0,tb=0):(sb=d.css("paddingTop")+" "+d.css("paddingRight")+" "+d.css("paddingBottom")+" "+d.css("paddingLeft"),tb=(parseInt(d.css("paddingLeft"),10)||0)+(parseInt(d.css("paddingRight"),10)||0)),a.extend(vb,{reinitialise:function(b){b=a.extend({},P,b),f(b)},scrollToElement:function(a,b,c){z(a,b,c)},scrollTo:function(a,b,c){y(a,c),x(b,c)},scrollToX:function(a,b){y(a,b)},scrollToY:function(a,b){x(a,b)},scrollToPercentX:function(a,b){y(a*(U-R),b)},scrollToPercentY:function(a,b){x(a*(V-S),b)},scrollBy:function(a,b,c){vb.scrollByX(a,c),vb.scrollByY(b,c)},scrollByX:function(a,b){var c=A()+Math[0>a?"floor":"ceil"](a),d=c/(U-R);t(d*cb,b)},scrollByY:function(a,b){var c=B()+Math[0>a?"floor":"ceil"](a),d=c/(V-S);r(d*_,b)},positionDragX:function(a,b){t(a,b)},positionDragY:function(a,b){r(a,b)},animate:function(a,b,c,d){var e={};e[b]=c,a.animate(e,{duration:P.animateDuration,easing:P.animateEase,queue:!1,step:d})},getContentPositionX:function(){return A()},getContentPositionY:function(){return B()},getContentWidth:function(){return U},getContentHeight:function(){return V},getPercentScrolledX:function(){return A()/(U-R)},getPercentScrolledY:function(){return B()/(V-S)},getIsScrollableH:function(){return Z},getIsScrollableV:function(){return Y},getContentPane:function(){return Q},scrollToBottom:function(a){r(_,a)},hijackInternalLinks:a.noop,destroy:function(){O()}}),f(e)}return d=a.extend({},a.fn.jScrollPane.defaults,d),a.each(["arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){d[this]=d[this]||d.speed}),this.each(function(){var b=a(this),c=b.data("jsp");c?c.reinitialise(d):(a("script",b).filter('[type="text/javascript"],:not([type])').remove(),c=new e(b,d),b.data("jsp",c))})},a.fn.jScrollPane.defaults={showArrows:!1,maintainPosition:!0,stickToBottom:!1,stickToRight:!1,clickOnTrack:!0,autoReinitialise:!1,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:!1,animateDuration:300,animateEase:"linear",hijackInternalLinks:!1,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:3,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:!1,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:!0,hideFocus:!1,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:.8}}(jQuery,this); \ No newline at end of file diff --git a/src/assets/js/libs/jquery/jquery.mousewheel.js b/src/assets/js/libs/jquery/jquery.mousewheel.js new file mode 100644 index 00000000..9d65c716 --- /dev/null +++ b/src/assets/js/libs/jquery/jquery.mousewheel.js @@ -0,0 +1,117 @@ +/*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) + * Licensed under the MIT License (LICENSE.txt). + * + * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. + * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. + * Thanks to: Seamus Leahy for adding deltaX and deltaY + * + * Version: 3.1.3 + * + * Requires: 1.2.2+ + */ + +(function (factory) { + if ( typeof define === 'function' && define.amd ) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS style for Browserify + module.exports = factory; + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { + + var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; + var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; + var lowestDelta, lowestDeltaXY; + + if ( $.event.fixHooks ) { + for ( var i = toFix.length; i; ) { + $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; + } + } + + $.event.special.mousewheel = { + setup: function() { + if ( this.addEventListener ) { + for ( var i = toBind.length; i; ) { + this.addEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, + + teardown: function() { + if ( this.removeEventListener ) { + for ( var i = toBind.length; i; ) { + this.removeEventListener( toBind[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } + }; + + $.fn.extend({ + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } + }); + + + function handler(event) { + var orgEvent = event || window.event, + args = [].slice.call(arguments, 1), + delta = 0, + deltaX = 0, + deltaY = 0, + absDelta = 0, + absDeltaXY = 0, + fn; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; + + // Old school scrollwheel delta + if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } + if ( orgEvent.detail ) { delta = orgEvent.detail * -1; } + + // New school wheel delta (wheel event) + if ( orgEvent.deltaY ) { + deltaY = orgEvent.deltaY * -1; + delta = deltaY; + } + if ( orgEvent.deltaX ) { + deltaX = orgEvent.deltaX; + delta = deltaX * -1; + } + + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } + + // Look for lowest delta to normalize the delta values + absDelta = Math.abs(delta); + if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } + absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX)); + if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } + + // Get a whole value for the deltas + fn = delta > 0 ? 'floor' : 'ceil'; + delta = Math[fn](delta / lowestDelta); + deltaX = Math[fn](deltaX / lowestDeltaXY); + deltaY = Math[fn](deltaY / lowestDeltaXY); + + // Add event and delta to the front of the arguments + args.unshift(event, delta, deltaX, deltaY); + + return ($.event.dispatch || $.event.handle).apply(this, args); + } + +}));