How to disable multi-select-component in ember-widgets - select

Is there any way to disable the multi-select-component from addepar's ember-widgets?
This works for the single select-component
{{select-component
contentBinding="selectCountries"
prompt="Select a Country"
value=selectSelected
disabled=true
}}
The same does not work for the multi-select-component
{{multi-select-component
contentBinding="selectCountries"
prompt="Select a Country"
selections=multiSelectSelected
disabled=true
}}
Here's a not-working JS bin example. I looked through the source code, there doesn't seem to be an option for this.

The fastest way I could think of doing it, short of editing the source code was this (updated JS bin):
I defined an Ember component that takes an array of strings (selections) as its only parameter. I used all the classes that are used by the multi-select-component so I didn't have to redefine all the CSS:
<script type="text/x-handlebars" id="components/disabled-multi-select">
<div class="ember-view ember-select multi-select-disabled" tabindex="-1">
<div class="ember-select-container ember-select-multi dropdown-toggle js-dropdown-toggle">
<ul class="form-control ember-select-choices">
{{#each selection in selections}}
<li class="ember-view ember-select-search-choice">
<div>{{selection}}</div>
<div class="ember-select-search-choice-close">×</div>
</li>
{{/each}}
</ul>
</div>
</div>
</script>
Then I added some css to make it look like a disabled select:
.ember-select.multi-select-disabled > .ember-select-container > .form-control {
cursor: not-allowed;
background-color: #EEE;
opacity: 1;
}
.ember-select.multi-select-disabled > .ember-select-container .ember-select-search-choice {
background-color: #D8D8D8;
cursor: not-allowed;
}
.ember-select.multi-select-disabled > .ember-select-container .ember-select-search-choice .ember-select-search-choice-close {
cursor: not-allowed;
}
.ember-select.multi-select-disabled > .ember-select-container .ember-select-search-choice .ember-select-search-choice-close:hover {
background-color: #D8D8D8;
}
It's used like this:
{{#if isInputDisabled}}
// Stick your multi-select-component in here
{{else}}
{{disabled-multi-select selections=multiSelectSelected}}
{{/if}}

Related

wrap content elements in specific pages differently

All of my content elements are wrapped using stdWrap.wrap.
I am looking for a solution to wrap content elements in the page which i have my ke_search added differently .
Why do you need another HTML-markup?
Normaly you have another <div> around your search results which should enable you to add another styling by CSS.
your page may look like:
<body>
<div class="header">
:
</div>
<div class="content">
<div id="C123">
<h3>my very special CE</h3>
<p class="bodytext">with some text to demonstrate.</p>
</div>
<div id="345">
<h3>your search results:</h3>
<div class="search-results">
<a href="index.php?id=67&s=special">
<div id="C123">
<h3>my very special CE</h3>
<p class="bodytext">with some text to demonstrate.</p>
</div>
</a>
<a href="index.php?id=83&s=special">
<div id="C52">
<h2>just a demo</h3>
<p class="bodytext">this text is nothing special.</p>
</div>
</a>
</div>
</div>
</div>
</body>
with appropiate CSS the first CE looks completely different to the same CE in the search results.
h3 { color:black; font-size:16px; }
p.bodytext { color:#444; font-size:12px; }
.search-results h3 { color:blue; font-size:10px; font-weight:bold; }
.search-results p.bodytext { color:#44b; font-size:10px; font-style:italics; }
I answer my own question:
You can conditionally wrap specific content elements using the following typoscript snippet.
tt_content {
stdWrap {
if.value = tx_kesearch_pi2
{
wrap = |
innerWrap >
}
wrap = <div class="someotherclass">|</div>
}
}

how to get all nested div heights using jQuery

How to get all heights from the div's nested inside the "GO" div:
<div id="GO" style="max-height: 100px;">
<div style="height: 569px;"></div>
<div style="height: 469px;"></div>
<div style="height: 269px;"></div>
<div style="height: 69px;"></div>
<div style="height: 169px;"></div>
</div>
<div id="STOP">
</div>
I tried using this code
var vales;
vales =$("#GO div").height();
//planB
vales =$("#GO").height();
But it didn't solve my problem
To iterate the children div's and get the height value, you can do something like this:
$("#GO > div").each(function() {
$(this).height();
});
As you can see you have many children divs in the parent one so you need to iterate over the children to get each of them. You can create a blank array and with use of each loop you can push the height values in it but i would suggest you to use .map() method which creates an array of returned values.
You can use .map().get():
var vales = $("#GO div").map(function(){
// return $(this).css('height'); // only if you want applied css values with 'px' etc.
return $(this).height();
}).get();
$('pre').html(JSON.stringify(vales));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre></pre>
<div id="GO" style="max-height: 100px;">
<div style="height: 569px;"></div>
<div style="height: 469px;"></div>
<div style="height: 269px;"></div>
<div style="height: 69px;"></div>
<div style="height: 169px;"></div>
</div>
<div id="STOP">
</div>
Do you want like this ?
$("#GO").children().each(function(){
$(this).height();
});

jQuery Click on next element

I have a problem with programming jQuery and I hope that you can help me even if a speak english like an alien %).
I'm doing a site with horizontal scrolling, you can see it here http://www.kinetics.ru/index_kin.html
I have a menu at the left and two buttons PREV and NEXT at the bottom.
Menu is working correctly, but I need to let the bottom buttons work.
By clicking for example on NEXT I need that code made a click on next menu btn after the one that have style 'on'.
The code is:
<div class="menu">
<ul class="nav">
<li id="main"><img src="img/menu/about.png" /></li>
<li><img src="img/menu/uslugi.png"/></li>
<li><img src="img/menu/portfolio.png"/></li>
<li><img src="img/menu/clients.png"/></li>
<li><img src="img/menu/contacts.png"/></li>
</ul>
</div>
...
<div class="bottomNav" style="position: absolute; z-index: 11">
<div style="height: 26px; width:98px; margin:-75px 0 0 500px; position: fixed" class="back"><img src="img/back.png"</div>
<div style="height: 26px; width:114px; margin:-25px 0 0 600px; position: fixed" id="next"><img src="img/forward.png"</div>
And my not working jQuery code for next btn:
$('bottomNav, #next img').click(function(){
if ($('ul.nav').find('img').hasClass('on')){
$('ul.nav').next().click();
}
});
Also I've tried to do like this:
$('bottomNav, #next img').click(function(){
$('ul.nav img').click(function(){
if ($(this).hasClass('on')){
$(this).next().click();}
});
});
P.S. Sorry for my noobish question. I just got a task at work to make a site and nobody cares that a designer is NOT the same as web-designer. I have no possibility to learn first, I have to learn and do at same time.
You have to review jQuery selectors and as well your HTML code, it's terribly wrong. Firebug says:
I modified your code in proper way:
<div class="bottomNav" style="position: absolute; z-index: 11">
<div id="prev" style="height: 26px; width:98px; margin:-75px 0 0 500px; position: fixed">
<img src="img/back.png" />
</div>
<div id="next" style="height: 26px; width:114px; margin:-25px 0 0 600px; position: fixed" >
<img src="img/forward.png" />
</div>
</div>
JavaScript (It's pretty simple and I didn't test it, but it should give you an idea).
$('#prev').click(function () {
var $activeLi = getActiveLi();
var $prevLi = $parentLi.prev();
if ($prevLi.length > 0) {
$prevLi.find('a').click();
}
});
$('#next').click(function () {
var $activeLi = getActiveLi();
var $nextLi = $parentLi.next();
if ($nextLi.length > 0) {
$nextLi.find('a').click();
}
});
function getActiveLi() {
var $activeImg = $('.menu .nav img.on');
var $activeLi = $activeImg.closest('li');
return $activeLi;
};
But beeing seriously: before continuing developing your web site you seriously should put some effort in learnin hot to use jQuery and how to structure HTML...
Solved!
Thank you again!
Your code was really helpfull.
I have modified it a little bit for my needs and also changed in line
var $activeLi = $activeImg.closest('li');
closest('li') to parents('li'), cause it wasn't working like that.
So now code looks like this:
$('#prev').click(function () {
var $prevLi = getActiveLi().prev();
if ($prevLi.length > 0){$prevLi.find('img').click();}
});
$('#next').click(function () {
var $nextLi = getActiveLi().next();
if ($nextLi.length > 0){$nextLi.find('img').click();}
});
function getActiveLi() {
var $activeImg = $('.menu .nav img.on');
var $activeLi = $activeImg.parents('li');
return $activeLi;
};
Also i guess, that i have understood why firebug was showing so big disaster in code... i have forgot to close the tag :)))
Anyway...MANY THANKS TO YOU!
P.S. third day reading a giant book about jQuery :)

iScroll 4 performance on iOS

I was impressed by the smoothness of the iScroll on iOS so i tried to implement it in my iPhone application.
The iScroll Demo works real fine on my iPhone. But only when the scrollable content is as simple as short text in <li> elements:
<ul id="thelist">
<li>Pretty row 1</li>
<li>Pretty row 2</li>
<li>Pretty row 3</li>
etc..
</ul>
When i tried to put a slightly more complex contents :
<ul>
<li class="GOE-WOTBDO GOE-WOTBIO GOE-WOTBEO " __idx="0">
<div class="cssDivStyle">
<img width="120px" height="74px" src="http://some_jpg_image.jpg">
</div>
<div>
<p>Some long text ....</p>
</div>
</li>
The smoothness is completely gone, and the list hardly scrolls ..
Is there a way to make my contents lighter ?
Any suggestions whatsoever ? Thank you very much !
Here's how i declare my iScroll element:
myScroll = new $wnd.iScroll(
elem,
{
useTransition : true,
topOffset : pullDownOffset,
hScroll : false,
onRefresh : function() {
if (pullDownEl.className.match('loading')) {
pullDownEl.className = 'pullDown';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
}
},
onScrollMove : function() {
if (this.y > 5 && !pullDownEl.className.match('flip')) {
pullDownEl.className = 'flip pullDown';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Release to refresh...';
this.minScrollY = 0;
}
},
onScrollEnd : function(response) {
if (pullDownEl.className.match('flip')) {
pullDownEl.className = 'loading pullDown';
pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';
app.#ma.xxx.xxxxx.clientcommon.utils.IPhoneScroller::callbackSuccess(Lcom/google/gwt/user/client/rpc/AsyncCallback;Lcom/google/gwt/core/client/JavaScriptObject;)(pullDownCallback,response);
}
}
});
[EDIT]
only by removing divs from:
<ul>
<li class="GOE-WOTBDO GOE-WOTBIO GOE-WOTBEO " __idx="0">
<div class="cssDivStyle">
<img width="120px" height="74px" src="http://some_jpg_image.jpg">
</div>
<div>
<p>Some long text ....</p>
</div>
</li>
and making it to:
<ul>
<li class="GOE-WOTBDO GOE-WOTBIO GOE-WOTBEO " __idx="0">
<img class="cssDivStyle" width="120px" height="74px" src="http://some_jpg_image.jpg">
<p>Some long text ....</p>
</li>
Made the scrolling much, much faster !! I have no idea why!
The code below will render your page the way webkit expects it. So redrawing will be massively quicker.
The HTML
<body>
<div class="headerFix">
<div class="header">
<!-- The content in header...logo/menu/e.t.c -->
</div>
</div>
<div class="content"><!-- you dont need this extra div but it keeps structure neat -->
<ul>
<li>List content here which can be as complex as needed</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
</div>
<div class="footerFix">
<div class="footer">
<!-- The content in footer -->
</div>
</div>
...
The css
.headerFix, .header {
height:50px; /*important to share width in both divs*/
width:100%;
background:red;
}
.headerFix, .footerFix {
position:relative;
}
.header {
position:fixed;
top:0;
left:0;
/*this is now fixed, but the parent being in flow keeps this div from overlapping your list which is why the height had to be the same for both*/
}
ul li {
/*basic list look for sample purposes*/
display:block;
min-height:40px;
border-bottom:solid 1px #777;
}
.footerFix, .footer {
height:50px; /*important to share width in both divs*/
width:100%;
background:red;
}
.footer {
position:fixed;
top:0;
left:0;
/*you will need to use javascript to find the height of device screen to know what the css value for "top" should really be. This will take some work on android where getting screen sizes is funky if you plan to support it. */
/*If its iphone only you can assume the size which has always been the same, and make an exception for the new iphone 6. I say use javascript to position this footer if you plan to support many platforms*/
}
By the way I recommend using this meta tag in your html head to make sure you use the screen at its best
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
When I use 'iscroll-lite.js' library in my mobile application, I fall same problem. Then I had little change in 'iscroll-lite.js' library.
Simply add e.preventDefault() to '_move:' function in 'iscroll-lite.js';
It resolve my problem.

jQuery connectToSortable Nested Lists and Greedy Option

I've been trying to resolve an issue for some time with connectToSortable and nested lists. I've created an example at jsfiddle that shows the basic code:
http://jsfiddle.net/ZYSYM/
What I would like to achieve is the ability for a user to drag a "New Item" from the right list into the sub items list. However, the issue is that it adds the item to both the sub and parent lists.
I've read that perhaps the Greedy option may resolve this, however I'm not sure if it's working correctly or I've misinterpreted how it's meant to work. I've googled and searched around but could not find anyone with the exact same issue.
I've also performed some debugging and the greedy option fires the line parentInstance._out.call(parentInstance, event); in jquery-ui, which I think is for this purpose, but it doesn't seem to have any affect.
I'm not an expert in jQuery so any help is greatly appreciated. Perhaps I've missed something simple or there's a better way of doing this?
Thanks and please let me know if you require any further information.
This is little trickier than simple cases:
The Html:
<div style="float: left;">
<ul id="list_1">
<li>Existing 1</li>
<li>Existing 2</li>
<li>
<ul id = "list_2">
<li><dl> <dt>Existing Sub 1</dt></dl></li>
<li>Existing Sub 2</li>
<li>Existing Sub 3</li>
<li>Existing Sub 4</li>
</ul>
</li>
<li>Existing 3</li>
<li>Existing 4</li>
</ul>
</div>
<div style="float: right; margin-top: 30px;">
<ul id="from_list">
<li class="new_item">New Item 1</li>
<li class="new_item">New Item 2</li>
<li class="new_item">New Item 3</li>
<li class="new_item">New Item 4</li>
</ul>
</div>
The CSS:
#list_1 .dropzone {
background-color: #FFFFFF;
border-bottom: 4px solid #FFFFFF;
height: 6px;
}
The Javascript:
var selector = '#list_1, #list_2';
$('#list_1 li').prepend('<div class="dropzone"></div>');
$('#list_1 li, #from_list li').draggable({
opacity: .8,
handle: ' > dl',
addClasses: false,
helper: 'clone',
zIndex: 100 }
);
$('#list_1 .dropzone').droppable({
accept: '#from_list li',
tolerance: 'pointer',
drop: function(e, ui) {
var li = $(this).parent();
var child = !$(this).hasClass('dropzone');
//If this is our first child, we'll need a ul to drop into.
if (child && li.children('ul').length == 0) {
li.append('<ul/>');
}
//ui.draggable is our reference to the item that's been dragged.
if (child) {
li.children('ul').append(ui.draggable);
}
else {
li.before(ui.draggable);
}
//reset our background colours.
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
},
over: function() {
$(this).filter('dl').css({ backgroundColor: '#ccc' });
$(this).filter('.dropzone').css({ borderColor: '#aaa' });
},
out: function() {
$(this).filter('dl').css({ backgroundColor: '' });
$(this).filter('.dropzone').css({ borderColor: '' });
}
});
You can see the result here:
http://jsfiddle.net/F3nck/
Credit due:
I found the solution and adapted to your example from:
http://boagworld.com/technology/creating-a-draggable-sitemap-with-jquery/