Skip to content

Commit

Permalink
$ isn't used in Drupal 7
Browse files Browse the repository at this point in the history
Drupal 7 uses jQuery in the no-conflict mode meaning that $ doesn't
equal jQuery automatically. So we'll just use jQuery to access the
jQuery object.
  • Loading branch information
KyleAMathews committed Oct 17, 2011
1 parent c9f0c0b commit fa370f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion fhd_easy_edit/brunch/build/web/js/app.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions fhd_easy_edit/brunch/src/app/main.coffee
Expand Up @@ -10,7 +10,7 @@ MainRouter = require('routers/main_router').MainRouter
HomeView = require('views/home_view').HomeView

# app bootstrapping on document ready
$(document).ready ->
jQuery(document).ready ->
app.initialize = ->
app.models.editing = new Editing()
app.models.stats = new Stats()
Expand All @@ -23,8 +23,8 @@ $(document).ready ->
window.converter = new Markdown.Converter()

window.renderMarkdown = ->
$('#markdown').html(window.converter.makeHtml(
"# " + $('#title').val() + "\n\n" + $('#body').val())
jQuery('#markdown').html(window.converter.makeHtml(
"# " + jQuery('#title').val() + "\n\n" + jQuery('#body').val())
)
app.models.editing.set title: $('#title').val(), { silent:true }
app.models.editing.set body: $('#body').val(), { silent:true }
app.models.editing.set title: jQuery('#title').val(), { silent:true }
app.models.editing.set body: jQuery('#body').val(), { silent:true }
2 changes: 1 addition & 1 deletion fhd_easy_edit/brunch/src/app/routers/main_router.coffee
Expand Up @@ -3,4 +3,4 @@ class exports.MainRouter extends Backbone.Router
"home": "home"

home: ->
$('body').html app.views.home.render().el
jQuery('body').html app.views.home.render().el
20 changes: 10 additions & 10 deletions fhd_easy_edit/brunch/src/app/views/home_view.coffee
Expand Up @@ -8,7 +8,7 @@ class exports.HomeView extends Backbone.View
app.models.editing.bind('change', @render)

render: =>
$(@el).html homeTemplate(
jQuery(@el).html homeTemplate(
editing: app.models.editing
stats: app.models.stats
)
Expand All @@ -21,7 +21,7 @@ class exports.HomeView extends Backbone.View
'click #save': 'save'

loadNew: =>
$.getJSON 'http://fhd-staging.eduglu.com/drupal-edit/next', (data, textStatus, jqXHR) =>
jQuery.getJSON 'http://fhd-staging.eduglu.com/drupal-edit/next', (data, textStatus, jqXHR) =>
# Change all H1s to H2s
changeh1Toh2 = /^#{1}\s/gm
data.markdown = data.markdown.replace(changeh1Toh2, '## ')
Expand All @@ -38,20 +38,20 @@ class exports.HomeView extends Backbone.View
console.log data

removeEndLines: ->
text = $('#body')[0]
text = jQuery('#body')[0]
lineEndings = /(\S)\n/gm

window.selectedText = $(text).val().substring(text.selectionStart, text.selectionEnd)
window.selectedText = jQuery(text).val().substring(text.selectionStart, text.selectionEnd)

# For each blank line, make it two spaces so that when we remove line
# endings, there'll still be a line break there.
selectedText = window.selectedText.replace(/^\n/gm, "\n\n")
selectedText = selectedText.replace(lineEndings, '$1 ')
# console.log selectedText
$(text).val(
$(text).val().substring(0, text.selectionStart) +
jQuery(text).val(
jQuery(text).val().substring(0, text.selectionStart) +
selectedText +
$(text).val().substring(text.selectionEnd)
jQuery(text).val().substring(text.selectionEnd)
)
renderMarkdown()

Expand All @@ -64,7 +64,7 @@ class exports.HomeView extends Backbone.View
title: app.models.editing.get('title')
body: app.models.editing.get('body')

$.post 'http://fhd-staging.eduglu.com/drupal-edit/save', node
jQuery.post 'http://fhd-staging.eduglu.com/drupal-edit/save', node

$('#tools').append('<span class="success">Node saved</span>')
setTimeout (-> $('#tools .success').fadeOut()), 5000
jQuery('#tools').append('<span class="success">Node saved</span>')
setTimeout (-> jQuery('#tools .success').fadeOut()), 5000
2 changes: 1 addition & 1 deletion fhd_easy_edit/brunch/src/app/views/stats_view.coffee
Expand Up @@ -6,6 +6,6 @@ class exports.StatsView extends Backbone.View
app.models.stats.bind('change', @render)

render: =>
$(@el).html statsTemplate(app.models.stats)
jQuery(@el).html statsTemplate(app.models.stats)
console.log 'rendering stats!'
@

0 comments on commit fa370f4

Please sign in to comment.