Bootstrap 3 Multiple Accordions on one page must assign data-parent values after the fact - twitter-bootstrap-3

Due to some restrictions with a CMS I am developing for I cannot create the intended markup for a proper accordion with Bootstrap 3 on page load, however I can get it very close.
The issue I am having is that the initial
panel group id (accordion1), I cannot assign the proper data-parent="accordion1" to the data-toggle="collapse" element in the panel. I am attempting to rewrite the data-parent references to the proper accordion ID but it does not have an affect, it is like the collapse binding is already in place and I'm not sure how to get around it.
This is an example of my issue. (id's are the same on page load but I try to rewrite them with a script on dom-ready)
$(document).ready(function() {
$('.panel-group').each(function() {
var $t = $(this);
var id = "#" + $t.attr("id");
$t.find('[data-parent]').attr("data-parent", id);
});
});
This function fixes the markup as BS3 wants but the functionality is still broken.
http://plnkr.co/CTBekXVyzU0xjzlud2N1

I ended up figuring out that the error was my own. Multiple accordions is not an issue. Where I went wrong was in the markup. The error in my ways weas that the data-toggle="collapse" element's href="#collapse-0" for example was duplicated for both accordions. They must be unique. The CMS restriction still existed on the data-parent however. This caused me to redo my script (which does work now for multiple accordions)
$('.panel-group').each(function(){
//setup each panel group with individual id's appropriately
var $t = $(this);
var id = "#" + $t.attr('id');
var randomInt = $t.attr('id').split('_')[1]; //extract
$t.find('.panel').each(function(){
//set the proper collapsable targets for each
var $t = $(this);
var $dataParent = $t.find('[data-parent]');
var href = $dataParent.attr('href');
//set the collapse target
var $targetId = $dataParent.attr('href', injectRandom(href, randomInt));
var targetId = $targetId.attr('href').split('#')[1];
//set the random id's
$dataParent.attr('data-parent', id);
//set the collapse container
$dataParent.parents('.panel-heading:first').next().attr('id', targetId);
});
//open first pane
$t.find('[data-toggle]:first').trigger('click');
});
I will update the plunkr

Related

Remove "MIME type" column from Filent Content List

I am Using a Script Adapter by passing payload to get contend for a Content List from "Search with values" event
When Contend get loaded to content list , i have a custom view to preview them. But if i clicked on MIME type column , It opens a separate view with the mapped viewer
So I need to remove this column or make it un-clickable
1) I am passing search values to content list's "Search with values" event , from where can i handle Content List's contend loading ,any Dojo Event i can use ?
2) With Script Adapter can i do this without going for a "response filter"
Edit :
As Nicely explained by "Ivo Jonker" (in his answer - "or try to specifically locate the widgets on your page" and with his example code)
responsed = page.ContentList8.ecmContentList.getResultSet();
var cols = responsed.structure.cells[0];
for (i=cols.length-1; i>0; i--){
var col = cols[i];
if (col.field=="mimeTypeIcon")
cols.splice(i,1);
}
page.ContentList78.ecmContentList.setResultSet(responsed);
I simply remove this row. Thanks Again and lovely blog , hope you keep posting more great articles.
The values passed through the Search With Values event will eventually be handled by the icm.pgwidget.contentlist.dijit.DocumentSearchHandler
that in turn creates a SearchTemplate to execute the search (ecm.model.SearchTemplate.prototype.search). One option would be to aspect/before/around the DocumentSearchHandler#query to manipulat the searchresults and by that way to remove the column.
The wiring however does not provide any handles to achieve this for a specific query-resultset combination leaving you to either fix this on a global scale (icm.pgwidget.contentlist.dijit.DocumentSearchHandler.prototype#query), or try to specifically locate the widgets on your page.
Personally, taking into account #2, i'd go for the responsefilter-option if you feel the global solution wouldn't be a problem, or alternatively i'd personally prefer to create a simple ICM widget that instantiates/implements a "plain" ecm.widget.listView.ContentList and exposes a wire to set the ecm.model.Resultset.
You'd then be able to create your own Searchquery in a scriptadapter, remove the column, and pass the resultset.
The script adapter could be something like:
var scriptadapter=this;
var queryParams={};
queryParams.query = "SELECT * FROM Document where id in /*your list*/";
queryParams.retrieveAllVersions = false;
queryParams.retrieveLatestVersion = true;
queryParams.repository = ecm.model.desktop.repositories[0];
queryParams.resultsDisplay = {
"sortBy": "{NAME}",
"sortAsc": true,
"columns": ["{NAME}"],
"honorNameProperty": true};
var searchQuery = new ecm.model.SearchQuery(queryParams);
searchQuery.search(function(response/*ecm.model.Resultset*/){
//remove the mimeTypeIcon
var cols = response.structure.cells[0];
for (i=cols.length-1; i>0; i--){
var col = cols[i];
if (col.field=="mimeTypeIcon")
cols.splice(i,1);
}
//emit the resultset to your new contentlist, be sure to block the regular synchrounous output of the scriptadapter
scriptadapter.onPublishEvent("icm.SendEventPayload",response);
//The contentlist wire would simply do contentlist.setResultSet(response);
});

%%GLOBAL variables not working in custom Bigcommerce templates

I want to customise the product template, but not for all cases hence I am creating a new template layout file.
I have tried to do this two ways, however both don't work and encounter the same issue with %%GLOBAL variables not working.
Using Product.html as a base, I created _Product.html and changed %%Panel.ProductDetails%% to my custom ProductDetails file %%Panel._ProductDetails%%, which I haven't customised at all at this stage. I then change a test product to use that template. When viewing the product, console errors ar produced and the page doesn't show properly. The cause of the first console error is a syntax error where script variables are being set to a %%GLOBAL variable. Looking at the page source, this is the result:
<script type="text/javascript">//<![CDATA[
var ThumbURLs = new Array();
var ProductImageDescriptions = new Array();
var CurrentProdThumbImage = ;
var ShowVariationThumb =false;
var ProductThumbWidth = ;
var ProductThumbHeight = ;
var ProductMaxZoomWidth = ;
var ProductMaxZoomHeight = ;
var ProductTinyWidth = ;
var ProductTinyHeight = ;
where the template is
<script type="text/javascript">//<![CDATA[
var ThumbURLs = new Array();
var ProductImageDescriptions = new Array();
var CurrentProdThumbImage = %%GLOBAL_CurrentProdThumbImage%%;
var ShowVariationThumb =false;
var ProductThumbWidth = %%GLOBAL_ProductThumbWidth%%;
var ProductThumbHeight = %%GLOBAL_ProductThumbHeight%%;
var ProductMaxZoomWidth = %%GLOBAL_ProductMaxZoomWidth%%;
var ProductMaxZoomHeight = %%GLOBAL_ProductMaxZoomHeight%%;
var ProductTinyWidth = %%GLOBAL_ProductMaxTinyWidth%%;
var ProductTinyHeight = %%GLOBAL_ProductMaxTinyHeight%%;
The weird part is that there are %%global variables just above it that work fine.
<script type="text/javascript" src="%%GLOBAL_CdnAppPath%%/javascript/jquery/plugins/jCarousel/jCarousel.js?%%GLOBAL_JSCacheToken%%"></script>
gets correctly gets interpreted as
<script type="text/javascript" src="http://cdn3.bigcommerce.com/r-8a870c678fbffbf4184af752aed70da3f3454036/javascript/jquery/plugins/jCarousel/jCarousel.js?"></script>
The second way I tried was to include everything in the top level template. Instead of linking to %%Panel._ProductDetails%%, I inserted the contents of that panel into _Product.html, however this also encounters exactly the same issue.
Does anyone know why neither of these options work and how I can achieve what I want?
You have to call Panel.ProductDetails prior to using those variables.
Even if you are using a custom product details alternative panel you need to reference the standard one first. Then your global variables will work.
This is because GLOBALS in the BigCommerce system will only print a value where they have been permitted by the BigCommerce development team. This can be a pain, especially for the values you are after, and what you want to do makes perfect sense.
At this time however, I suggest you make it known to the developers you want this at http://ideas.bigcommerce.com.
I can't say whether this will change anytime soon as the main reason for the GLOBALS being banned in certain areas is for security, although the ones you are after are useful, and I don't see why they aren't enabled either. Who knows, the developers may surprise us.

Sitefinity get current dynamiccontent item from code

I'm currently writing a site using Sitefinity CMS. Can someone please explain how to get the current dynamic content item from server side code on page_load?
I have written a user control to display a custom gallery of sliding images. There are multiple content types in my dynamic module. The user control will sit as part of the masterpage template rather than on every page. On each page load I would like to fetch the current dynamiccontent item that is associated with the page and examine whether it has a property with the name 'Gallery'. If so I would then extract the images and render them via the usercontrol.
Thanks,
Brian.
I'm assuming your images are related content. This gets every published content item of your type.
var dynamicModuleManager = DynamicModuleManager.GetManager();
var moduleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.YOURTYPEHERE");
var dcItems = dynamicModuleManager.GetDataItems(moduleType)
.Where(l => l.Status == ContentLifecycleStatus.Master);
foreach (var dcItem in dcItems)
{
//pass the dynamic content item to a model constructor or populate here, then
// get your image this way:
var image = dcItem.GetRelatedItems<Image>("Images").SingleOrDefault();
if (image != null)
{
ImageUrl = image.MediaUrl;
}
}

How to search a row in current page in dojo EnhancedGrid

I need build a search functionality for a grid which binds with QueryReadStore. I tried using Search plugin but I think that work if you the grid is bind with ItemFileReadStore . Can someone help how to achieve search on QueryReadyStore?
var grid_obj = dijit.byId(your_grid_id);
var grid_row_count = grid_obj.rowCount;
for(i =0 i<grid_row_count;i++)
{
var item = grid_obj.getItem(i);
// Then compare for the value
}
//Note:this is full grid scan,dont use if there is large data.

Rally Cardboard render : Add item to card header

I want to add a value from a custom user attribute to the header of the cards in the default cardboard Kanban app. I added the following to the render function :
.....
var idDiv = document.createElement("div");
dojo.addClass(idDiv, "leftCardHeader");
header.appendChild(idDiv);
// MY NEW CODE
if(item.Domain && item.Domain.length > 0) {
var domainDiv = document.createElement("div");
domainDiv.appendChild(document.createTextNode(
" Domain: " + item.Domain));
header.appendChild(domainDiv);
}
// END MY NEW CODE
var ownerImg = document.createElement("img");
dojo.addClass(ownerImg, "cardOwner");
var ownerName = document.createElement("div");
dojo.addClass(ownerName, "cardOwnerName");
header.appendChild(ownerImg);
header.appendChild(ownerName);
....
This adds the text value to the card header but in doing so it pushes the owner name and image down a row in alignment. I have looked at the CSS but don't see any formating that is sting length dependent but I am still relatively new to this area. I tried changing the font size in the CSS but that didn't change anything adding the above code always pushes the owner name and owner image down a line.
Any help on what I might be doing wrong or if there is a cleaner way to dothis is appreciated.
You are appending a div, which is a block element- that is why you are getting the new line. You could either add a style of float:left to this element so it lines up next to the id or you could put the div in the card body instead- you may find it looks better there (especially on narrow width cards).