Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move twitter bootstrap as plain css to css templates

  • Loading branch information...
commit 89ce12708d81c8ccafc843229dbdc04a119866cc 1 parent ce9a714
Yuguang Zhang authored
2  static/files/viewer.local.html
View
@@ -4,7 +4,7 @@
<title>HTML/CSS Live Reload</title>
<meta name="description" content="Python Fiddle runs Python compiled to JavaScript without reloading the iframe and updates the page automatically once the HTML/CSS changes."/>
<style id="user_css"></style>
- <script type="text/javascript" src="http://127.0.0.1:8000/static/files/head.min.js"></script>
+ <script type="text/javascript" src="head.min.js"></script>
</head>
<body>
<script type="text/javascript">
22 static/js/fiddle-engine.coffee
View
@@ -414,6 +414,7 @@ serverCompiler =
This routine calls execute to compile code either when a major code block is completed or after a period of time.
http://codemirror.net/doc/manual.html#option_onChange
###
+ return if _.isEmpty(editor) or _.isEmpty(change)
# if a code block is completed
if change.next? and change.next.from.ch is 0
@execute()
@@ -499,13 +500,23 @@ CssViewer = Viewer.$extend(
__init__: (id) ->
@$super id
@mode = name: 'css'
- unless view_model.newFiddle
- @set_code = _.after 2, @set_code
- set_code: (css) ->
+ setIframeCss: (css) ->
cssElement = document.getElementById(@id).contentWindow.css
cssElement.textContent = css
document.getElementById(@id).contentWindow.Highlight.init(cssElement)
+
+ set_code: (css) ->
+ if viewModel.newFiddle()
+ @setIframeCss css
+ else
+ timer = setInterval(
+ =>
+ if document.getElementById(@id)?.contentWindow?.loaded
+ @setIframeCss css
+ clearInterval timer
+ 250
+ )
)
JavascriptViewer = Viewer.$extend(
__init__: (id) ->
@@ -603,6 +614,7 @@ FiddleEditor = Class.$extend(
viewModel.containers @layoutFrames()
$('#viewer').appendTo('#result').show()
root.codeRunner = CodeRunner()
+ viewModel.add_resource(if debug then base_url + '/js/jquery-1.7.1.js' else 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js')
@styleEditor.load()
@documentEditor.load()
@@ -710,7 +722,7 @@ FiddleEditor = Class.$extend(
previewFrame = Frame 'source', 'Source'
tabs = TabInterface 'source-tab'
preview = IframeComponent @id.css
- preview.set_source if debug then base_url + '/files/csspreviewer.html' else 'http://fiddlesalad.com/home/files/csspreviewer.html?v=2012033019'
+ preview.set_source if debug then base_url + '/files/csspreviewer.html' else 'http://fiddlesalad.com/home/files/csspreviewer.html?v=2012041516'
index = tabs.add 'css', preview.to_html_string()
@styleEditor.set_focus_listener PreviewListener('source', index)
@@ -858,7 +870,7 @@ CodeRunner = Class.$extend(
__init__: ->
frame = document.getElementById('viewer')
@window = (if frame.contentWindow then frame.contentWindow else (if frame.contentDocument.document then frame.contentDocument.document else frame.contentDocument))
- @scripts = (if debug then [ base_url + '/js/jquery-1.7.1.js', base_url + '/js/prettyprint.js' ] else [ 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', base_url + '/js/prettyprint.js' ])
+ @scripts = [base_url + '/js/prettyprint.js']
@synchronizeNextExecution()
@template =
css: _.template '<link rel="stylesheet" type="text/css" href="<%= source %>" />'
11 static/js/frameworks.js
View
2 additions, 9 deletions not shown
30 static/js/model.coffee
View
@@ -455,7 +455,7 @@ FiddleViewModel = ViewModel.$extend(
templateLibrary =
css:
title: 'CSS Framework'
- templates: ['inuit', 'html5boilerplate']
+ templates: ['inuit', 'html5boilerplate', 'twitterbootstrap']
type: 'css'
html:
title: 'HTML Boilerplate'
@@ -494,24 +494,28 @@ FiddleViewModel = ViewModel.$extend(
fileName =
css: 'styles'
html: 'index'
-
- i = 0
-
- while i < @starterTemplates.length
- unless @starterTemplates[i].type.indexOf(type) is -1
- if _.isString(@starterTemplates[i].selected())
- template = @starterTemplates[i].selected()
- templateType = @starterTemplates[i].type
- i++
+ languageType =
+ css: LANGUAGE_TYPE.STYLE
+ html: LANGUAGE_TYPE.DOCUMENT
+
+ for starterTemplate in @starterTemplates
+ unless starterTemplate.type.indexOf(type) is -1
+ if _.isString(starterTemplate.selected())
+ template = starterTemplate.selected()
+ templateType = starterTemplate.type
if _.isString(template) and template.length > 0
if templateType is 'css/html'
templatePath = [ 'templates/', template, '/', fileName[type] ].join('')
else
templatePath = template
templatePath = [ ajax_url, '/files/', templatePath, '.', type ].join('')
- $.get templatePath, {}, ((code) ->
- engine.set_code code, type
- ), 'text'
+ if type is 'css' and templateType isnt 'css/html'
+ @add_resource templatePath
+ else
+ $.get templatePath, {}, ((code) =>
+ @disableLint()
+ engine.set_code code, languageType[type]
+ ), 'text'
name: template
url: templatePath
Please sign in to comment.
Something went wrong with that request. Please try again.