This repository has been archived by the owner on Apr 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Directly reference jQuery and not $ #267
Open
jordanbyron
wants to merge
3
commits into
volmer:master
Choose a base branch
from
jordanbyron:jquery-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,96 @@ | ||
/* global Bootsy */ | ||
|
||
window.Bootsy = window.Bootsy || {}; | ||
|
||
Bootsy.Area = function($el) { | ||
var self = this; | ||
|
||
this.$el = $el; | ||
this.unsavedChanges = false; | ||
this.locale = $el.data('bootsy-locale') || $('html').attr('lang'); | ||
if (!$.fn.wysihtml5.locale.hasOwnProperty(this.locale)) this.locale = 'en'; | ||
|
||
this.options = { | ||
locale: this.locale, | ||
alertUnsavedChanges: $el.data('bootsy-alert-unsaved'), | ||
uploader: $el.data('bootsy-uploader'), | ||
color: $el.data('bootsy-color'), | ||
emphasis: $el.data('bootsy-emphasis'), | ||
'font-styles': $el.data('bootsy-font-styles'), | ||
html: $el.data('bootsy-html'), | ||
image: $el.data('bootsy-image'), | ||
link: $el.data('bootsy-link'), | ||
lists: $el.data('bootsy-lists'), | ||
events: { | ||
change: function() { | ||
self.unsavedChanges = true; | ||
$el.trigger('change'); | ||
(function($) { | ||
/* global Bootsy */ | ||
|
||
window.Bootsy = window.Bootsy || {}; | ||
|
||
Bootsy.Area = function($el) { | ||
var self = this; | ||
|
||
this.$el = $el; | ||
this.unsavedChanges = false; | ||
this.locale = $el.data("bootsy-locale") || $("html").attr("lang"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why single quotes? |
||
if (!$.fn.wysihtml5.locale.hasOwnProperty(this.locale)) this.locale = "en"; | ||
|
||
this.options = { | ||
locale: this.locale, | ||
alertUnsavedChanges: $el.data("bootsy-alert-unsaved"), | ||
uploader: $el.data("bootsy-uploader"), | ||
color: $el.data("bootsy-color"), | ||
emphasis: $el.data("bootsy-emphasis"), | ||
"font-styles": $el.data("bootsy-font-styles"), | ||
html: $el.data("bootsy-html"), | ||
image: $el.data("bootsy-image"), | ||
link: $el.data("bootsy-link"), | ||
lists: $el.data("bootsy-lists"), | ||
events: { | ||
change: function() { | ||
self.unsavedChanges = true; | ||
$el.trigger("change"); | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
}; | ||
|
||
// Alert for unsaved changes | ||
Bootsy.Area.prototype.unsavedChangesAlert = function () { | ||
if (this.unsavedChanges) { | ||
return $.fn.wysihtml5.locale[this.locale].bootsy.alertUnsaved; | ||
} | ||
}; | ||
|
||
// Clear everything | ||
Bootsy.Area.prototype.clear = function () { | ||
this.editor.clear(); | ||
this.setImageGalleryId(''); | ||
this.modal.$el.data('gallery-loaded', false); | ||
}; | ||
|
||
Bootsy.Area.prototype.setImageGalleryId = function(id) { | ||
this.$el.data('gallery-id', id); | ||
this.$el.siblings('.bootsy_image_gallery_id').val(id); | ||
}; | ||
|
||
// Init components | ||
Bootsy.Area.prototype.init = function() { | ||
if (!this.$el.data('bootsy-initialized')) { | ||
if ((this.options.image === true) && (this.options.uploader === true)) { | ||
this.modal = new Bootsy.Modal(this); | ||
this.options.image = false; | ||
this.options.customCommand = true; | ||
this.options.customCommandCallback = this.modal.show.bind(this.modal); | ||
this.options.customTemplates = { customCommand: Bootsy.imageTemplate }; | ||
|
||
// Alert for unsaved changes | ||
Bootsy.Area.prototype.unsavedChangesAlert = function() { | ||
if (this.unsavedChanges) { | ||
return $.fn.wysihtml5.locale[this.locale].bootsy.alertUnsaved; | ||
} | ||
}; | ||
|
||
this.editor = this.$el.wysihtml5($.extend(true, {}, Bootsy.options, this.options)).data('wysihtml5').editor; | ||
// Clear everything | ||
Bootsy.Area.prototype.clear = function() { | ||
this.editor.clear(); | ||
this.setImageGalleryId(""); | ||
this.modal.$el.data("gallery-loaded", false); | ||
}; | ||
|
||
// Mechanism for unsaved changes alert | ||
if (this.options.alertUnsavedChanges !== false) { | ||
window.onbeforeunload = this.unsavedChangesAlert.bind(this); | ||
} | ||
Bootsy.Area.prototype.setImageGalleryId = function(id) { | ||
this.$el.data("gallery-id", id); | ||
this.$el.siblings(".bootsy_image_gallery_id").val(id); | ||
}; | ||
|
||
this.$el.closest('form').submit(function() { | ||
this.unsavedChanges = false; | ||
// Init components | ||
Bootsy.Area.prototype.init = function() { | ||
if (!this.$el.data("bootsy-initialized")) { | ||
if (this.options.image === true && this.options.uploader === true) { | ||
this.modal = new Bootsy.Modal(this); | ||
this.options.image = false; | ||
this.options.customCommand = true; | ||
this.options.customCommandCallback = this.modal.show.bind(this.modal); | ||
this.options.customTemplates = { customCommand: Bootsy.imageTemplate }; | ||
} | ||
|
||
return true; | ||
}.bind(this)); | ||
this.editor = this.$el | ||
.wysihtml5($.extend(true, {}, Bootsy.options, this.options)) | ||
.data("wysihtml5").editor; | ||
|
||
this.$el.data('bootsy-initialized', true); | ||
} | ||
}; | ||
// Mechanism for unsaved changes alert | ||
if (this.options.alertUnsavedChanges !== false) { | ||
window.onbeforeunload = this.unsavedChangesAlert.bind(this); | ||
} | ||
|
||
// Insert image in the text | ||
Bootsy.Area.prototype.insertImage = function(image) { | ||
this.editor.currentView.element.focus(); | ||
this.$el.closest("form").submit( | ||
function() { | ||
this.unsavedChanges = false; | ||
|
||
if (this.caretBookmark) { | ||
this.editor.composer.selection.setBookmark(this.caretBookmark); | ||
this.caretBookmark = null; | ||
} | ||
return true; | ||
}.bind(this) | ||
); | ||
|
||
this.editor.composer.commands.exec('insertImage', image); | ||
}; | ||
this.$el.data("bootsy-initialized", true); | ||
} | ||
}; | ||
|
||
// Insert image in the text | ||
Bootsy.Area.prototype.insertImage = function(image) { | ||
this.editor.currentView.element.focus(); | ||
|
||
if (this.caretBookmark) { | ||
this.editor.composer.selection.setBookmark(this.caretBookmark); | ||
this.caretBookmark = null; | ||
} | ||
|
||
this.editor.composer.commands.exec("insertImage", image); | ||
}; | ||
})(jQuery); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,49 @@ | ||
window.Bootsy = window.Bootsy || {}; | ||
(function($) { | ||
window.Bootsy = window.Bootsy || {}; | ||
|
||
var pageStylesheets = []; | ||
$('link[rel="stylesheet"]').each(function () { | ||
pageStylesheets.push($(this).attr('href')); | ||
}); | ||
var pageStylesheets = []; | ||
$('link[rel="stylesheet"]').each(function() { | ||
pageStylesheets.push($(this).attr("href")); | ||
}); | ||
|
||
window.Bootsy.options = {}; | ||
window.Bootsy.options = {}; | ||
|
||
$.extend(true, window.Bootsy.options, $.fn.wysihtml5.defaultOptions, { | ||
parserRules: { | ||
classes: { | ||
"wysiwyg-float-left": 1, | ||
"wysiwyg-float-right": 1, | ||
"wysiwyg-float-inline": 1 | ||
}, | ||
tags: { | ||
"cite": { | ||
"check_attributes": { | ||
"title": "alt" | ||
} | ||
$.extend(true, window.Bootsy.options, $.fn.wysihtml5.defaultOptions, { | ||
parserRules: { | ||
classes: { | ||
"wysiwyg-float-left": 1, | ||
"wysiwyg-float-right": 1, | ||
"wysiwyg-float-inline": 1 | ||
}, | ||
"img": { | ||
"check_attributes": { | ||
"src": "src" | ||
tags: { | ||
cite: { | ||
check_attributes: { | ||
title: "alt" | ||
} | ||
}, | ||
"add_class": { | ||
"align": "align_img" | ||
} | ||
}, | ||
// this allows youtube embed codes | ||
"iframe": { | ||
set_attributes: { | ||
"frameborder": "0", | ||
"allowfullscreen": "1" | ||
img: { | ||
check_attributes: { | ||
src: "src" | ||
}, | ||
add_class: { | ||
align: "align_img" | ||
} | ||
}, | ||
check_attributes: { | ||
"width": "numbers", | ||
"height": "numbers", | ||
"src": "href" | ||
// this allows youtube embed codes | ||
iframe: { | ||
set_attributes: { | ||
frameborder: "0", | ||
allowfullscreen: "1" | ||
}, | ||
check_attributes: { | ||
width: "numbers", | ||
height: "numbers", | ||
src: "href" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
color: true, | ||
stylesheets: pageStylesheets | ||
}); | ||
}, | ||
color: true, | ||
stylesheets: pageStylesheets | ||
}); | ||
})(jQuery); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
/* global Bootsy */ | ||
window.Bootsy = window.Bootsy || {}; | ||
(function($) { | ||
/* global Bootsy */ | ||
window.Bootsy = window.Bootsy || {}; | ||
|
||
// Public: Intialize Bootsy editors in all visible `textarea` | ||
// elements that has the `bootsy_text_area` class. | ||
Bootsy.init = function() { | ||
if (!Bootsy.areas) { | ||
Bootsy.areas = {}; | ||
} | ||
// Public: Intialize Bootsy editors in all visible `textarea` | ||
// elements that has the `bootsy_text_area` class. | ||
Bootsy.init = function() { | ||
if (!Bootsy.areas) { | ||
Bootsy.areas = {}; | ||
} | ||
|
||
$('textarea.bootsy_text_area').each(function(index) { | ||
if (!$(this).data('bootsy-initialized')) { | ||
var area = new Bootsy.Area($(this)); | ||
var areaIdx = $(this).attr('id') || index; | ||
$("textarea.bootsy_text_area").each(function(index) { | ||
if (!$(this).data("bootsy-initialized")) { | ||
var area = new Bootsy.Area($(this)); | ||
var areaIdx = $(this).attr("id") || index; | ||
|
||
/* There's always people who let elements share ids */ | ||
if(Bootsy.areas[areaIdx] !== undefined) { | ||
areaIdx = $(this).attr('id') + index; | ||
} | ||
/* There's always people who let elements share ids */ | ||
if (Bootsy.areas[areaIdx] !== undefined) { | ||
areaIdx = $(this).attr("id") + index; | ||
} | ||
|
||
area.init(); | ||
area.init(); | ||
|
||
Bootsy.areas[areaIdx] = area; | ||
} | ||
}); | ||
}; | ||
Bootsy.areas[areaIdx] = area; | ||
} | ||
}); | ||
}; | ||
|
||
/* Initialize Bootsy on document load */ | ||
$(function() { | ||
$(window).on('load', function() { | ||
Bootsy.init(); | ||
/* Initialize Bootsy on document load */ | ||
$(function() { | ||
$(window).on("load", function() { | ||
Bootsy.init(); | ||
|
||
/* Reload Bootsy on page load when using Turbolinks. */ | ||
document.addEventListener('turbolinks:load', Bootsy.init); | ||
/* Reload Bootsy on page load when using Turbolinks. */ | ||
document.addEventListener("turbolinks:load", Bootsy.init); | ||
}); | ||
}); | ||
}); | ||
})(jQuery); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Bootstrap 3 fully installed in your app" already implies that jQuery is required.