Module: BitsnoteAssets::ActionViewExtensions
- Defined in:
- lib/bitsnote-assets.rb
Constant Summary collapse
- OFFLINE =
(::Rails.env.development? or ::Rails.env.test?)
- JQUERY_VERSION =
::Jquery::Rails::JQUERY_VERSION
- JQUERY_UI_VERSION =
"1.11.1"- ANGULAR_VERSION =
'1.2.23'- BOOTSTRAP_VERSION =
"3.2.0"- FONTAWESOME_VERSION =
"4.1.0"- MOMENT_VERSION =
"2.8.2"- FULLCALENDAR_VERSION =
"2.1.0"- SPIN_VERSION =
"2.0.1"- PICKADATE_VERSION =
"3.5.3"- CODEMIRROR_VERSION =
"4.5.0"- MASONRY_VERSION =
"3.1.5"- GOOGLE_CDN =
"//ajax.googleapis.com/ajax/libs"- BOOTSTRAP_CDN =
"//maxcdn.bootstrapcdn.com"- CDNJS =
"//cdnjs.cloudflare.com/ajax/libs"- CDNS =
{ :jquery_js => { :google => "#{GOOGLE_CDN}/jquery/#{JQUERY_VERSION}/jquery.min.js", :microsoft => "//ajax.aspnetcdn.com/ajax/jQuery/jquery-#{JQUERY_VERSION}.min.js", :jquery => "//code.jquery.com/jquery-#{JQUERY_VERSION}.min.js", :yandex => "//yandex.st/jquery/#{JQUERY_VERSION}/jquery.min.js", :cloudflare => "#{CDNJS}/jquery/#{JQUERY_VERSION}/jquery.min.js" }, :jquery_ui_js => { :google => "#{GOOGLE_CDN}/jqueryui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :microsoft => "//ajax.aspnetcdn.com/ajax/jquery.ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :jquery => "//code.jquery.com/ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js", :yandex => "//yandex.st/jquery-ui/#{JQUERY_UI_VERSION}/jquery-ui.min.js" }, :angular_js => { :default => "#{GOOGLE_CDN}/angularjs/#{ANGULAR_VERSION}/angular.min.js" }, :bootstrap_js => { :default => "#{BOOTSTRAP_CDN}/bootstrap/#{BOOTSTRAP_VERSION}/js/bootstrap.min.js" }, :bootstrap_css => { :default => "#{BOOTSTRAP_CDN}/bootstrap/#{BOOTSTRAP_VERSION}/css/bootstrap.min.css" }, :bootstrap_theme_css => { :default => "#{BOOTSTRAP_CDN}/bootstrap/#{BOOTSTRAP_VERSION}/css/bootstrap-theme.min.css" }, :fontawesome_css => { :default => "#{BOOTSTRAP_CDN}/font-awesome/#{FONTAWESOME_VERSION}/css/font-awesome.min.css" }, :moment_js => { :default => "#{CDNJS}/moment.js/#{MOMENT_VERSION}/moment.min.js" }, :moment_locales_js => { :default => "#{CDNJS}/moment.js/#{MOMENT_VERSION}/moment-with-locales.min.js" }, :fullcalendar_js => { :default => "#{CDNJS}/fullcalendar/#{FULLCALENDAR_VERSION}/fullcalendar.min.js" }, :fullcalendar_css => { :default => "#{CDNJS}/fullcalendar/#{FULLCALENDAR_VERSION}/fullcalendar.min.css" }, :spin_js => { :default => "#{CDNJS}/spin.js/#{SPIN_VERSION}/spin.min.js" }, :codemirror_js => { :default => "#{CDNJS}/codemirror/#{CODEMIRROR_VERSION}/codemirror.min.js" }, :codemirror_markdown_js => { :default => "#{CDNJS}/codemirror/#{CODEMIRROR_VERSION}/mode/markdown/markdown.min.js" }, :codemirror_css => { :default => "#{CDNJS}/codemirror/#{CODEMIRROR_VERSION}/codemirror.min.css" }, :masonry_js => { :default => "#{CDNJS}/masonry/#{MASONRY_VERSION}/masonry.pkgd.min.js" }, }
Instance Method Summary collapse
- #angular_js_include_tag(name, options = {}) ⇒ Object
- #bootstrap_css_include_tag(name, options = {}) ⇒ Object
- #bootstrap_js_include_tag(name, options = {}) ⇒ Object
- #bootstrap_theme_css_include_tag(name, options = {}) ⇒ Object
- #codemirror_css_include_tag(name, options = {}) ⇒ Object
- #codemirror_js_include_tag(name, options = {}) ⇒ Object
- #codemirror_markdown_js_include_tag(name, options = {}) ⇒ Object
- #css_include_tag(cdn, asset, url, options = {}) ⇒ Object
- #fontawesome_css_include_tag(name, options = {}) ⇒ Object
- #fullcalendar_css_include_tag(name, options = {}) ⇒ Object
- #fullcalendar_js_include_tag(name, options = {}) ⇒ Object
- #jquery_include_tag(name, options = {}) ⇒ Object
- #jquery_ui_include_tag(name, options = {}) ⇒ Object
- #js_include_tag(cdn, asset, url, options = {}) ⇒ Object
- #masonry_js_include_tag(name, options = {}) ⇒ Object
- #moment_js_include_tag(name, options = {}) ⇒ Object
- #moment_locales_js_include_tag(name, options = {}) ⇒ Object
- #spin_js_include_tag(name, options = {}) ⇒ Object
Instance Method Details
#angular_js_include_tag(name, options = {}) ⇒ Object
149 150 151 152 153 |
# File 'lib/bitsnote-assets.rb', line 149 def angular_js_include_tag(name, = {}) js_include_tag(name, 'angular/angular', :angular_js_url, ) do |asset| "window.angular" end end |
#bootstrap_css_include_tag(name, options = {}) ⇒ Object
137 138 139 |
# File 'lib/bitsnote-assets.rb', line 137 def bootstrap_css_include_tag(name, = {}) css_include_tag(name, 'bootstrap/bootstrap', :bootstrap_css_url, ) end |
#bootstrap_js_include_tag(name, options = {}) ⇒ Object
131 132 133 134 135 |
# File 'lib/bitsnote-assets.rb', line 131 def bootstrap_js_include_tag(name, = {}) js_include_tag(name, 'bootstrap/bootstrap', :bootstrap_js_url, ) do |asset| "typeof $().carousel == 'function'" end end |
#bootstrap_theme_css_include_tag(name, options = {}) ⇒ Object
141 142 143 |
# File 'lib/bitsnote-assets.rb', line 141 def bootstrap_theme_css_include_tag(name, = {}) css_include_tag(name, 'bootstrap/bootstrap-theme', :bootstrap_theme_css_url, ) end |
#codemirror_css_include_tag(name, options = {}) ⇒ Object
193 194 195 |
# File 'lib/bitsnote-assets.rb', line 193 def codemirror_css_include_tag(name, = {}) css_include_tag(name, 'codemirror', :codemirror_css_url, ) end |
#codemirror_js_include_tag(name, options = {}) ⇒ Object
181 182 183 184 185 |
# File 'lib/bitsnote-assets.rb', line 181 def codemirror_js_include_tag(name, = {}) js_include_tag(name, 'codemirror', :codemirror_js_url, ) do |asset| "window.CodeMirror" end end |
#codemirror_markdown_js_include_tag(name, options = {}) ⇒ Object
187 188 189 190 191 |
# File 'lib/bitsnote-assets.rb', line 187 def codemirror_markdown_js_include_tag(name, = {}) js_include_tag(name, 'codemirror/modes/markdown', :codemirror_markdown_js_url, ) do "window.CodeMirror.modes.markdown" end end |
#css_include_tag(cdn, asset, url, options = {}) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/bitsnote-assets.rb', line 107 def css_include_tag(cdn, asset, url, = {}) asset = asset + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) return stylesheet_link_tag(asset, ) else # CSS do not offer way to check existing [ stylesheet_link_tag(self.send(url, cdn.to_sym), ), ].join("\n").html_safe end end |
#fontawesome_css_include_tag(name, options = {}) ⇒ Object
145 146 147 |
# File 'lib/bitsnote-assets.rb', line 145 def fontawesome_css_include_tag(name, = {}) css_include_tag(name, 'font-awesome', :fontawesome_css_url, ) end |
#fullcalendar_css_include_tag(name, options = {}) ⇒ Object
171 172 173 |
# File 'lib/bitsnote-assets.rb', line 171 def fullcalendar_css_include_tag(name, = {}) css_include_tag(name, 'fullcalendar/fullcalendar', :fullcalendar_css_url, ) end |
#fullcalendar_js_include_tag(name, options = {}) ⇒ Object
167 168 169 |
# File 'lib/bitsnote-assets.rb', line 167 def fullcalendar_js_include_tag(name, = {}) js_include_tag(name, 'fullcalendar/fullcalendar', :fullcalendar_js_url, ) end |
#jquery_include_tag(name, options = {}) ⇒ Object
119 120 121 122 123 |
# File 'lib/bitsnote-assets.rb', line 119 def jquery_include_tag(name, = {}) js_include_tag(name, 'jquery', :jquery_js_url, ) do |asset| "window.jQuery" end end |
#jquery_ui_include_tag(name, options = {}) ⇒ Object
125 126 127 128 129 |
# File 'lib/bitsnote-assets.rb', line 125 def jquery_ui_include_tag(name, = {}) js_include_tag(name, 'jquery-ui/jquery-ui', :jquery_ui_js_url, ) do |asset| "window.jQuery.ui" end end |
#js_include_tag(cdn, asset, url, options = {}) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/bitsnote-assets.rb', line 88 def js_include_tag(cdn, asset, url, = {}) .reverse_merge! :local_copy => false asset = asset + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) .delete(:local_copy) # not used in OFFLINE mode return javascript_include_tag(asset, ) else local_copy = .delete(:local_copy) j = [ javascript_include_tag(self.send(url, cdn.to_sym), ) ] if local_copy && block_given? v = yield(asset) j << javascript_tag("#{v} || document.write(unescape('#{javascript_include_tag(asset, options).gsub('<','%3C')}'))") end j.join("\n").html_safe end end |
#masonry_js_include_tag(name, options = {}) ⇒ Object
197 198 199 200 201 |
# File 'lib/bitsnote-assets.rb', line 197 def masonry_js_include_tag(name, = {}) js_include_tag(name, 'masonry/masonry.pkgd', :masonry_js_url, ) do |asset| "window.Masonry" end end |
#moment_js_include_tag(name, options = {}) ⇒ Object
155 156 157 158 159 |
# File 'lib/bitsnote-assets.rb', line 155 def moment_js_include_tag(name, = {}) js_include_tag(name, 'moment/moment', :moment_js_url, ) do |asset| "window.moment" end end |
#moment_locales_js_include_tag(name, options = {}) ⇒ Object
161 162 163 164 165 |
# File 'lib/bitsnote-assets.rb', line 161 def moment_locales_js_include_tag(name, = {}) js_include_tag(name, 'moment/moment-with-locales', :moment_locales_js_url, ) do |asset| "window.moment" end end |
#spin_js_include_tag(name, options = {}) ⇒ Object
175 176 177 178 179 |
# File 'lib/bitsnote-assets.rb', line 175 def spin_js_include_tag(name, = {}) js_include_tag(name, 'spin/spin', :spin_js_url, ) do |asset| "window.Spinner" end end |