JSFiddle - React, Tailwind, and code Playground
by jarnal
HTML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.2.0/ui-bootstrap-tpls.js"></script>
<script src="https://quizr.azure-mobile.net/client/MobileServices.Web-1.0.0.min.js"></script>
<script src="http://code.angularjs.org/1.0.7/angular-cookies.js"></script>
<div ng-app='quizWiz'>
<h2>Quiz</h2>
<div ng-controller="QuestionCtrl">
<button ng-click="test22()"> Insert test item</button>
<ul ui-sortable rename-this-class="unstyled">
<li ng-init="editmode=false" ng-repeat="question in questions" ng-show="$index==current" >
<span>{{$index+1}} of {{questions.length}}</span>
<c2e value="question.text"> </c2e>
<span>[<a href ng:click="deleteQuestion($index)">X</a>]</span>
<ul >
<li ng-repeat="option in question.options">
<button ng-click="question.selectedOption=option" ng-disabled="question.selectedOption" >{{option}}</button>
</li>
</ul>
<div ng-show="question.selectedOption">
<span>Result:{{question.result()}}</span>
<span>Answer:{{question.answer}}</span>
<span>Selected:{{question.selectedOption}}</span><br>
<span> Explanation:{{question.explanation && question.explanation || 'None provided' }}</span>
<br><button ng-click="next()" class="btn-primary" >next>></button>
</div>
</li>
</ul>
<form ng-submit="addQuestion()">
<input type="text" ng-model="questionText" size="80"
placeholder="type new question here"><br>
<input type="text"...
CSS
</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>-->
<style>
.edit-in-place span {
cursor: pointer;
}
.edit-in-place input {
display: none;
}
.edit-in-place.active span {
display: none;
}
.edit-in-place.active input {
display: inline-block;
}
JavaScript
angular.module('quizWiz',[]).directive('blur', function () {
return function (scope, elem, attrs) {
elem.bind('blur', function () {
scope.$apply(attrs.blur);
});
};
});
var app=angular.module('quizWiz',['ui','ngCookies']);
app.directive( 'c2e', function() {
return {
restrict: 'E',
scope: { value: '=' },
template: '<span ng-click="edit()" ng-bind="value"></span><input ng-model="value"></input>',
link: function ( $scope, element, attrs ) {
// Let's get a reference to the input element, as we'll want to reference it.
var inputElement = angular.element( element.children()[1] ); //gets a reference to the input element (inserted by template) and casts it to an angular element object
// This directive should have a set class so we can style it.
element.addClass( 'edit-in-place' );
// Initially, we're not editing.
$scope.editing = false;
// ng-click handler to activate edit-in-place
$scope.edit = function () {
$scope.editing = true;
// We control display through a class on the directive itself. See the CSS.
element.addClass( 'active' );
// And we must focus the element.
// `angular.element()` provides a chainable array, like jQuery so to access a native DOM function,
// we have to reference the first element in the array.
inputElement[0].focus();
};
// When we leave the input, we're done editing.
inputElement.prop( 'onblur', function() { //set the onblur property of the inout element
$scope.editing = false;
element.removeClass( 'active' );
});
}
};
});
app.factory('AzureMobileClient', ['$cookieStore', function ($cookieStore) {
var azureMobileClient = {};
azureMobileClient.isLoggedIn = false;
azureMobileClient.azureError = "";
azureMobileClient.azureMSC = new...