This is an automated email from the git hooks/post-receive script. New commit to branch feature/882 in repository chorem. See http://git.chorem.org/chorem.git commit b40dc7324f66811de07fc2c64db4a07b211e105e Author: kootox <jean.couteau@gmail.com> Date: Wed Feb 4 14:30:19 2015 +0100 refs #882 : Clean Bootcards and PJax calls js, removing all reference to mobile browsing, target is desktop --- .../webmotion/actions/crm/CompaniesAction.java | 1 + .../src/main/webapp/WEB-INF/jsp/crm/companies.jsp | 230 +-------------------- chorem-webmotion/src/main/webapp/js/crm.js | 72 +++++++ 3 files changed, 76 insertions(+), 227 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java index 73818ef..39ab445 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java @@ -8,6 +8,7 @@ import org.debux.webmotion.server.render.RenderView; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; +import javax.servlet.http.HttpServletRequest; import java.util.List; public class CompaniesAction extends WebMotionController { diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp index 2647236..783f7eb 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp @@ -33,7 +33,7 @@ <div class="row"> - <div class="col-sm-6 bootcards-list" id="list" data-title="Companies"> + <div class="col-sm-6 bootcards-list" id="list"> <div class="panel panel-default"> <div class="panel-body"> <div class="search-form"> @@ -72,7 +72,7 @@ </div> - <div class="col-sm-6 bootcards-cards hidden-xs" id="listDetails"> + <div class="col-sm-6 bootcards-cards" id="listDetails"> <!-- company info card --> <%@include file="cards/companyInfoCard.jsp" %> @@ -134,230 +134,6 @@ enableTabletPortraitMode : true, disableRubberBanding : true }); - - //enable FastClick - window.addEventListener('load', function() { - FastClick.attach(document.body); - }, false); - - //activate the sub-menu options in the offcanvas menu - $('.collapse').collapse(); - - //highlight first list group option (if non active yet) - if ( $('.list-group a.active').length === 0 ) { - $('.list-group a').first().addClass('active'); - } - - /* - * Add click handlers to links to force a pjax (partial) load - * http://pjax.heroku.com/ - */ - bootcards.addPJaxHandlers = function(pjaxTarget) { - - //add pjax click handler to links - $('a.pjax').off().on('click', function(e) { - var $this = $(this); - var tgtUrl = $this.attr('href'); - - $.pjax( { - container : pjaxTarget, - url : tgtUrl - }); - - //add active class if this is a list item (removing it from all siblings) - if ($this.hasClass('list-group-item')) { - $this - .addClass('active') - .siblings() - .removeClass('active'); - } - - e.preventDefault(); - }); - - }; - - //pjax on all a's that have the data-pjax attribute (the attribute's value is the pjax target container) - $(document).ready( function() { - - //publish event when changing main menu option - $("a[data-title]").on("click", function() { - $.Topic( "navigateTo" ).publish( $(this).data("title") ); - }); - - var $body = $("body"); - - //fix for status bar bug in iOS 8 - if (bootcards.isFullScreen) { - $body - .prepend("<div class='statusbar' />") - .addClass("fullscreen"); - } - - //destroy modals on close (to reload the contents when using the remote property) - $body.on('hidden.bs.modal', '.modal', function () { - $(this).removeData('bs.modal'); - }); - - var pjaxTarget = (bootcards.isXS() ? '#list' : '#listDetails'); - - if (bootcards.isXS() ) { - - //restrict footer to only 4 items - var $footer = $(".navbar-fixed-bottom .btn-group"); - if ($footer.length>0) { - var $links = $('a', $footer); - - if ($links.length > 4) { - $links.each( function(idx) { - if (idx >= 4) { this.remove(); } - }); - } - } - - } - - bootcards.addPJaxHandlers(pjaxTarget); - - $(document) - .pjax('a[data-pjax]') - .on('submit', 'form[data-pjax]', function(event) { - //use pjax to submit forms - $.pjax.submit(event); - }) - .on('pjax:start', function(event) { - - //hide the offcanvas menu - $("#offCanvasMenu").removeClass("active"); - $("#main").removeClass("active"); - - }) - .on('pjax:end', function(event) { - - var $tgt = $(event.target); - var tgtId = $tgt.attr('id'); - - if ( bootcards.isXS() ) { - //function only performed on small screens (smartphones) - - //we only use the list column - var details = $('#listDetails'); - if (details.length>0) { - details.remove(); - } - - //change class on container elements (list>card and vice versa) - if ( tgtId == 'main') { - - $('#list') - .removeClass('bootcards-cards') - .addClass('bootcards-list'); - - //show the back button - $('.btn-menu').removeClass('hidden'); - $('.btn-back').addClass('hidden'); - - //get the panel - var $main = $("#main"); - var $panel = $("#main > .panel"); - if ($panel.length>0) { - - var row = $('<div class="row"></div>'); - var container = $('<div class="col-sm-5 bootcards-list" id="list"></div>') - .appendTo(row); - - $panel.appendTo(container); - - row.appendTo($main); - } - - } else if (tgtId == 'list') { - - var $list = $('#list'); - - if ( !$list.hasClass('bootcards-cards')) { - - $list - .addClass('bootcards-cards') - .removeClass('bootcards-list'); - - //show the menu button - $('.btn-menu').addClass('hidden'); - $('.btn-back').removeClass('hidden'); - - //scroll to the top of the card - $list.animate({scrollTop:0}, '500', 'easeOutExpo'); - } - - } - - } - - bootcards.addPJaxHandlers(pjaxTarget); - - //highlight first list group option (if non active yet) - if ( $('.list-group a.active').length === 0 ) { - $('.list-group a').first().addClass('active'); - } - - //enable single pane portrait mode when loading content with pjax - if ( tgtId == 'main' && bootcards.portraitModeEnabled ) { - - //do some cleaning up first - if (bootcards.listOffcanvasToggle) { - bootcards.listOffcanvasToggle.remove(); - bootcards.listTitleEl.remove(); - Bootcards.OffCanvas.$menuTitleEl.remove(); - } - bootcards.listOffcanvasToggle = null; - bootcards.listTitleEl = null; - Bootcards.OffCanvas.$menuTitleEl = null; - bootcards.listEl = null; - bootcards.cardsEl = null; - - bootcards._setOrientation(true); - - if (bootcards.listTitleEl) { - bootcards.listTitleEl.find('button').show(); - } - - //add the resize events again - $(window) - .off() - .on( 'resize', function() { - setTimeout( function() { - bootcards._setOrientation(false); - if (chartSalesProductType !== null) { chartSalesProductType.redraw(); } - if (closedSalesChart !== null) { closedSalesChart.redraw(); } - if (dbSizeChart !== null) { dbSizeChart.redraw(); } - if (barChartClosedSales !== null) { barChartClosedSales.redraw(); } - } , 250); - } ); - - } - - }) - .on('pjax:complete', function(event) { - //called after a pjax content update - - //check for any modals to close - var modal = $(event.relatedTarget).closest('.modal'); - if (modal.length) { - modal.modal('hide'); - } - - }); - - }); - - - /* - * Enable FTLabs' FastClick - * https://github.com/ftlabs/fastclick - */ - window.addEventListener('load', function() { - FastClick.attach(document.body); - }, false); - </script> + <script src="<c:url value='/js/crm.js'/>"></script> </body> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js new file mode 100644 index 0000000..7bee651 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -0,0 +1,72 @@ +//highlight first list group option (if non active yet) +if ( $('.list-group a.active').length === 0 ) { + $('.list-group a').first().addClass('active'); +} + +//pjax +bootcards.addPJaxHandlers = function(){ + //add pjax click handler to links + $('a.pjax').off().on('click', function(e) { + var $this = $(this); + var tgtUrl = $this.attr('href'); + + $.pjax( { + container : '#listDetails', + url : tgtUrl + }); + + //add active class if this is a list item (removing it from all siblings) + if ($this.hasClass('list-group-item')) { + $this + .addClass('active') + .siblings() + .removeClass('active'); + } + + e.preventDefault(); + }); + //$(document).pjax('a[data-target]') +} + + //pjax on all a's that have the data-pjax attribute (the attribute's value is the pjax target container) + $(document).ready( function() { + + var $body = $("body"); + + //destroy modals on close (to reload the contents when using the remote property) + $body.on('hidden.bs.modal', '.modal', function () { + $(this).removeData('bs.modal'); + }); + + bootcards.addPJaxHandlers(); + + $(document) + .pjax('a[data-pjax]') + .on('submit', 'form[data-pjax]', function(event) { + //use pjax to submit forms + $.pjax.submit(event); + }) + .on('pjax:end', function(event) { + + var $tgt = $(event.target); + var tgtId = $tgt.attr('id'); + + bootcards.addPJaxHandlers(); + + //highlight first list group option (if non active yet) + if ( $('.list-group a.active').length === 0 ) { + $('.list-group a').first().addClass('active'); + } + }) + .on('pjax:complete', function(event) { + //called after a pjax content update + + //check for any modals to close + var modal = $(event.relatedTarget).closest('.modal'); + if (modal.length) { + modal.modal('hide'); + } + + }); + + }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.