tenon 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dfb548908695c38e60f7abe4b367fc01dfd23ad
4
- data.tar.gz: 3b459fbfb37b249878e3eb640873d90526f8eb49
3
+ metadata.gz: 369fe222b4d39f614783304c9fd028c9904725cf
4
+ data.tar.gz: 9f19f960370d70a89fee8416e981c1174e90b11d
5
5
  SHA512:
6
- metadata.gz: 6ff4f71707443668d98d351e48ff8b67c87e43487f28ed6de5be21e0a74e1d5551297abcbe5a49eb26a46e0c15acc9ee17bc791cbc6967b2005615f65a6880b9
7
- data.tar.gz: 428b4ddb9985664ef8802f824eca53c20c622dbc3a65c557985046e8b97894fe345f30eb53c80e31b76b68732ff62fed409e6efd48be7bc917db5bc1a72e7acc
6
+ metadata.gz: 706543fb1b96546c2e7a1c3ad728cce2fa166e997830e8c1f9b559dd053ca9af7c56e97f6f2431707e2471003278b9ed4761bd2a7bf03736a42e5820fe1557af
7
+ data.tar.gz: 92683d22c2b17aa0daeff1482eb11d9e0d714d63740c972861d32563a7b7b84af22ada7a3d3fb1a52396700a6295681d79138f763c59970538ab476be14e25f7
@@ -1,5 +1,5 @@
1
- class Tenon.features.tenonContent.AssetLink extends Tenon.features.tenonContent.AssetAttachment
1
+ class Tenon.features.tenonContent.ImageAssetLink extends Tenon.features.tenonContent.AssetAttachment
2
2
  _setFields: ($li) =>
3
3
  $input = @$browseButton.closest('div').find('input')
4
4
  $input[0].value = $li.data('style-urls')['original']
5
- Tenon.mediumEditor.createLink($input[0])
5
+ Tenon.activeImageControlsLinkForm.saveForm()
@@ -11,4 +11,5 @@ class Tenon.features.tenonContent.Base
11
11
  new Tenon.features.tenonContent.LibraryFilter($container)
12
12
  new Tenon.features.tenonContent.PopOut($container)
13
13
  new Tenon.features.tenonContent.Sortable($container)
14
- new Tenon.features.tenonContent.WrappedSizing($container)
14
+ new Tenon.features.tenonContent.WrappedSizing($container)
15
+ new Tenon.features.tenonContent.ImageLinks($container)
@@ -0,0 +1,5 @@
1
+ class Tenon.features.tenonContent.AssetLink extends Tenon.features.tenonContent.AssetAttachment
2
+ _setFields: ($li) =>
3
+ $input = @$browseButton.closest('div').find('input')
4
+ $input[0].value = $li.data('style-urls')['original']
5
+ Tenon.mediumEditor.createLink($input[0])
@@ -8,26 +8,33 @@ class Tenon.features.tenonContent.ImageControls
8
8
  @_buildControls(e)
9
9
  e.stopImmediatePropagation()
10
10
 
11
+ showControls: (x, y) =>
12
+ x ||= @previousX
13
+ y ||= @previousY
14
+ @$controls.appendTo('body').css
15
+ left: @_leftOffset(x)
16
+ top: y + 'px'
17
+ display: 'block'
18
+
19
+ @previousX = x
20
+ @previousY = y
21
+
11
22
  hideControls: =>
12
23
  $('body > .image-controls').hide()
13
24
  $('.tooltip').remove()
14
25
 
15
26
  _removeControls: =>
16
27
  $('body > .image-controls').remove()
28
+ delete Tenon.activeImageControls
17
29
 
18
30
  _buildControls: (e) =>
19
31
  @_removeControls()
32
+ Tenon.activeImageControls = this
20
33
  $img = $(e.currentTarget)
21
34
  @$image = $img.closest('.image')
22
35
  @$controls = @$image.find('.image-controls').clone()
23
36
  @_tagControls()
24
- @_showControls(e.pageX, e.pageY)
25
-
26
- _showControls: (left, top) =>
27
- @$controls.appendTo('body').css
28
- left: @_leftOffset(left)
29
- top: top + 'px'
30
- display: 'block'
37
+ @showControls(e.pageX, e.pageY)
31
38
 
32
39
  _tagControls: =>
33
40
  # Add some data for use in operations
@@ -0,0 +1,52 @@
1
+ class Tenon.features.tenonContent.ImageLinks
2
+ constructor: (@$container) ->
3
+ $(document).on('click', '.column-image .add-link, .wrapped-image .add-link', @buildLinkForm)
4
+
5
+ buildLinkForm: (e) =>
6
+ @$button = $(e.currentTarget)
7
+ @$image = @_getImage(e)
8
+ @$form = @$image.find('.link-form')
9
+ @$visibleForm = @$form.clone()
10
+ @_showLinkForm()
11
+ @_bindLinkForm()
12
+ Tenon.activeImageControlsLinkForm = this
13
+
14
+ saveForm: =>
15
+ @$form.replaceWith(@$visibleForm)
16
+ @_setButtonActiveState()
17
+ Tenon.activeImageControls.showControls()
18
+
19
+ _showLinkForm: (e) =>
20
+ Tenon.activeImageControls.hideControls()
21
+ @$visibleForm.appendTo('body').css
22
+ left: @_leftOffset(Tenon.activeImageControls.previousX)
23
+ top: Tenon.activeImageControls.previousY - 75
24
+ display: 'block'
25
+
26
+ _getImage: (e) =>
27
+ $(e.currentTarget)
28
+ .closest('.image-controls')
29
+ .data('image')
30
+
31
+ _leftOffset: (left) =>
32
+ if $(window).width() < 641
33
+ (($(window).width() - @$visibleForm.width()) / 2) + 'px'
34
+ else
35
+ left - (@$visibleForm.width() / 2) + 'px'
36
+
37
+ _bindLinkForm: =>
38
+ @$visibleForm.on('keyup', 'input', @_formFilled)
39
+ @$visibleForm.on('click', '.medium-editor-cancel', @_cancel)
40
+
41
+ _formFilled: (e) =>
42
+ @saveForm() if e.keyCode == 13
43
+
44
+ _cancel: (e) => @$visibleForm.remove()
45
+
46
+ _setButtonActiveState: (e) =>
47
+ if @$visibleForm.find('input').val() != ''
48
+ @$button.addClass('medium-editor-button-active')
49
+ @$image.find('.add-link').addClass('medium-editor-button-active')
50
+ else
51
+ @$button.removeClass('medium-editor-button-active')
52
+ @$image.find('.add-link').removeClass('medium-editor-button-active')
@@ -241,6 +241,10 @@
241
241
  outline: none;
242
242
  background: lighten($tn-primary, 10%);
243
243
  }
244
+
245
+ .link-form {
246
+ z-index: $tn-z-medium-editor-controls;
247
+ }
244
248
  }
245
249
 
246
250
  [contenteditable=true]:empty:not(:focus):before {
@@ -15,6 +15,12 @@ $tn-z-content-popped-backdrop: 1020;
15
15
  $tn-z-content-popped: 1029;
16
16
  $tn-z-tc-sizer: 1029;
17
17
 
18
+ // medium
19
+ // MEDIUM DOES NOT ACTUALLY USE THIS VARIABLE
20
+ // THIS IS JUST HERE SO YOU CAN INDEX THINGS RELATIVE TO MEDIUM
21
+ $tn-z-medium-editor-controls: 2000;
22
+
23
+
18
24
  // modals
19
25
  $tn-z-modal-backdrop: 2030;
20
26
  $tn-z-asset-cropping: 2040;
@@ -6,7 +6,15 @@ module Tenon
6
6
  else
7
7
  i = image_tag(default_asset_thumbnail(asset))
8
8
  end
9
- link_to(i, [:edit, asset], default_options)
9
+ asset_icon_link(asset, i)
10
+ end
11
+
12
+ def asset_icon_link(asset, icon)
13
+ if asset.is_image?
14
+ link_to(icon, [:crop, asset], crop_options(asset))
15
+ else
16
+ link_to(icon, asset.attachment.url, target: '_')
17
+ end
10
18
  end
11
19
 
12
20
  def default_asset_thumbnail(asset)
@@ -19,6 +27,16 @@ module Tenon
19
27
 
20
28
  private
21
29
 
30
+ def crop_options(asset)
31
+ {
32
+ class: 'asset-crop',
33
+ data: {
34
+ 'asset-id' => asset.id,
35
+ 'post-crop-handler' => 'Tenon.features.AssetListPostCropHandler'
36
+ }
37
+ }
38
+ end
39
+
22
40
  def default_options
23
41
  {
24
42
  'data-modal-remote' => true,
@@ -1,5 +1,8 @@
1
1
  .tn-tc-image
2
- = image_tag(piece.image.url(:_medium))
2
+ - if piece.link_url.blank?
3
+ = image_tag(piece.image.url(:_medium))
4
+ - else
5
+ = link_to image_tag(piece.image.url(:_medium)), piece.link_url, target: '_'
3
6
  - if piece.show_caption
4
7
  .tn-tc-caption
5
8
  = piece.caption
@@ -11,6 +11,12 @@
11
11
  = f.super_text_area :caption, class: 'caption', placeholder: 'Enter caption here...', style: ("display: none;" unless f.object.show_caption)
12
12
  = f.hidden_field :show_caption
13
13
 
14
+ .medium-editor-toolbar-form-anchor.link-form{style: 'position: absolute; z-index: 2000;'}
15
+ = f.super_text_field :link_url, placeholder: 'Paste or type a link', style: 'display; inline; width: 316px;';
16
+ = link_to new_item_asset_path(hide_upload: true), 'title' => 'Link to an Asset', 'data-modal-remote' => 'true', 'data-modal-handler' => 'Tenon.features.tenonContent.ImageAssetLink', 'data-modal-title' => 'Link to Asset', 'data-tooltip' => true do
17
+ %i.fa.fa-file-pdf-o
18
+ = link_to '&times;'.html_safe, '#', class: 'medium-editor-cancel'
19
+
14
20
  .medium-editor-toolbar.medium-toolbar-arrow-under.medium-editor-toolbar-active.image-controls{style: "display: none; margin-top: -65px;"}
15
21
  %ul.medium-editor-toolbar-actions.clearfix
16
22
  %li
@@ -30,6 +36,10 @@
30
36
  %button{title: 'Swap Sides', class: 'swap-sides medium-editor-action', data: {tooltip: true}}
31
37
  %i.fa.fa-arrows-h
32
38
 
39
+ %li
40
+ %button.add-link.medium-editor-action{title: 'Add Link', class: ('medium-editor-button-active' unless f.object.link_url.blank?), data: {tooltip: true}}
41
+ %i.fa.fa-link
42
+
33
43
  %li
34
44
  %button{href: new_item_asset_path, title: 'Replace Image', class: 'replace-image medium-editor-action medium-editor-button-last', data: {'modal-remote' => 'true', 'modal-title' => "Select Image", 'modal-handler' => 'Tenon.features.tenonContent.AssetAttachment', 'tooltip' => true}}
35
45
  %i.fa.fa-picture-o
data/lib/tenon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tenon
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - factor[e] design initiative
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_errors
@@ -960,7 +960,9 @@ files:
960
960
  - app/assets/javascripts/tenon/features/tenon_content/column_swap.js.coffee
961
961
  - app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
962
962
  - app/assets/javascripts/tenon/features/tenon_content/embedded_content_modal_handler.js.coffee
963
+ - app/assets/javascripts/tenon/features/tenon_content/image_asset_link.js.coffee
963
964
  - app/assets/javascripts/tenon/features/tenon_content/image_controls.js.coffee
965
+ - app/assets/javascripts/tenon/features/tenon_content/image_links.js.coffee
964
966
  - app/assets/javascripts/tenon/features/tenon_content/library.js.coffee
965
967
  - app/assets/javascripts/tenon/features/tenon_content/library_filter.js.coffee
966
968
  - app/assets/javascripts/tenon/features/tenon_content/pop_out.js.coffee