/** * @license AngularJS v1.0.5 * (c) 2010-2012 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular, undefined) { 'use strict'; var directive = {}; var service = { value: {} }; var DEPENDENCIES = { 'angular.js': 'http://code.angularjs.org/' + angular.version.full + '/angular.min.js', 'angular-resource.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-resource.min.js', 'angular-sanitize.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-sanitize.min.js', 'angular-cookies.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-cookies.min.js' }; function escape(text) { return text. replace(/\&/g, '&'). replace(/\/g, '>'). replace(/"/g, '"'); } /** * http://stackoverflow.com/questions/451486/pre-tag-loses-line-breaks-when-setting-innerhtml-in-ie * http://stackoverflow.com/questions/195363/inserting-a-newline-into-a-pre-tag-ie-javascript */ function setHtmlIe8SafeWay(element, html) { var newElement = angular.element('
' + html + '
'); element.html(''); element.append(newElement.contents()); return element; } directive.jsFiddle = function(getEmbeddedTemplate, escape, script) { return { terminal: true, link: function(scope, element, attr) { var name = '', stylesheet = '\n', fields = { html: '', css: '', js: '' }; angular.forEach(attr.jsFiddle.split(' '), function(file, index) { var fileType = file.split('.')[1]; if (fileType == 'html') { if (index == 0) { fields[fileType] += '
\n' + getEmbeddedTemplate(file, 2); } else { fields[fileType] += '\n\n\n \n' + ' \n'; } } else { fields[fileType] += getEmbeddedTemplate(file) + '\n'; } }); fields.html += '
\n'; setHtmlIe8SafeWay(element, '
' + hiddenField('title', 'AngularJS Example: ' + name) + hiddenField('css', ' \n' + stylesheet + script.angular + (attr.resource ? script.resource : '') + '');