This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
// create an instance of PrimarySelect2 and attach to our Troop selector | |
// we set no special Select2 options. you could pass the normal Select2 options struct here, it will be passed to Select2 constructor | |
var s2Options = {}; | |
var ps2 = PrimarySelect2($('#Troops'), s2Options); | |
// ps2 is your handle now to the PrimarySelect2 interface | |
// if you're in a dynamic form later during your cleanup just call | |
// ps2.destroy(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set up a facade to handle interacting with the PrimarySelect2 | |
function PrimarySelect2($element, s2Options) { | |
// reality check | |
if (!$element || !$element.length) return; | |
// implementing on more than one item is left as an exercise for the reader. suggest jQuery plugin pattern | |
$element = $element.first(); | |
// pass the options straight through to Select2 | |
$element.select2(s2Options); | |
// get a handle to the Select2 api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="Troops">Troops</label> | |
<select name="Troops" id="Troops" multiple="" class="primary-selectable"> | |
<option value="1">Barbarian</option> | |
<option value="2">Archer</option> | |
<option value="3">Goblin</option> | |
<option value="4">Giant</option> | |
<option value="5" selected="selected">Wall Breaker</option> | |
<option value="6">Balloon</option> | |
<option value="7" selected="selected">Wizard</option> | |
<option value="8">Healer</option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function has3d(){ | |
var el = document.createElement('p'), | |
has3d, | |
transforms = { | |
'webkitTransform':'-webkit-transform', | |
'OTransform':'-o-transform', | |
'msTransform':'-ms-transform', | |
'MozTransform':'-moz-transform', | |
'transform':'transform' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>iscrollview Demo</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/> | |
<meta name="apple-mobile-web-app-capable" content="yes"/> | |
<meta name="apple-mobile-web-app-status-bar-style" content="black"/> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input[data-type="range"] {display: none} | |
div.ui-slider {display:block; margin:0.17em auto 0.6em auto; width: 85%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.bindingHandlers.slider = { | |
init: function (element, valueAccessor) { | |
// use setTimeout with 0 to run this after Knockout is done | |
setTimeout(function () { | |
// $(element) doesn't work as that has been removed from the DOM | |
var curSlider = $('#' + element.id); | |
// helper function that updates the slider and refreshes the thumb location | |
function setSliderValue(newValue) { | |
curSlider.val(newValue).slider('refresh'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- the refreshListview here instructs Knockout to call a binding handler by that name --> | |
<!-- ko foreach: members, refreshListview: true | |
--><li style="padding:.3em"> | |
<span data-bind="text: memberName, css: { memberIsTyping: isTyping }"></span> | |
</li><!-- /ko --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- the Knockout binding from the text input to the chatRoomViewModel's | |
currentChatInput property. notice the valueUpdate is set to afterkeydown, | |
so the viewModel will be updated with each keystroke --> | |
<input type="text" data-mini="true" placeholder="chat" | |
data-bind="value: currentChatInput, valueUpdate: 'afterkeydown'" /> |
NewerOlder