diff --git a/backend/app/assets/javascripts/spree/backend.js b/backend/app/assets/javascripts/spree/backend.js
index 2401d4153a6..800f34e19b6 100644
--- a/backend/app/assets/javascripts/spree/backend.js
+++ b/backend/app/assets/javascripts/spree/backend.js
@@ -7,7 +7,6 @@
//= require modernizr
//= require jquery.cookie
//= require jquery.jstree/jquery.jstree
-//= require jquery.alerts/jquery.alerts
//= require jquery.powertip
//= require jquery.vAlign
//= require equalize
diff --git a/backend/app/assets/javascripts/spree/backend/taxonomy.js.coffee b/backend/app/assets/javascripts/spree/backend/taxonomy.js.coffee
index d365b8c3bad..6a4eda05b27 100644
--- a/backend/app/assets/javascripts/spree/backend/taxonomy.js.coffee
+++ b/backend/app/assets/javascripts/spree/backend/taxonomy.js.coffee
@@ -1,25 +1,27 @@
-handle_ajax_error = (XMLHttpRequest, textStatus, errorThrown) ->
- $.jstree.rollback(last_rollback)
- $("#ajax_error").show().html("" + server_error + "
" + taxonomy_tree_error)
+base_url = null
+
+tree_error_handler = (data) ->
+ rollback = data.rlbk
+ (XMLHttpRequest, textStatus, errorThrown) ->
+ $.jstree.rollback(rollback)
+ $("#ajax_error").show().html("#{server_error}
" + taxonomy_tree_error)
handle_move = (e, data) ->
- last_rollback = data.rlbk
position = data.rslt.cp
node = data.rslt.o
new_parent = data.rslt.np
url = "#{base_url}/#{node.prop("id")}"
Spree.ajax
- type: "POST",
+ type: "PUT",
dataType: "json",
url: url,
- data: ({_method: "put", "taxon[parent_id]": new_parent.prop("id"), "taxon[child_index]": position }),
- error: handle_ajax_error
+ data: ({"taxon[parent_id]": new_parent.prop("id"), "taxon[child_index]": position }),
+ error: tree_error_handler(data)
true
handle_create = (e, data) ->
- last_rollback = data.rlbk
node = data.rslt.obj
name = data.rslt.name
position = data.rslt.position
@@ -28,61 +30,50 @@ handle_create = (e, data) ->
Spree.ajax
type: "POST",
dataType: "json",
- url: base_url.toString(),
+ url: base_url,
data: {
"taxon[name]": name,
"taxon[parent_id]": new_parent.prop("id"),
"taxon[child_index]": position,
- token: Spree.api_key
},
- error: handle_ajax_error,
+ error: tree_error_handler(data)
success: (data,result) ->
node.prop('id', data.id)
handle_rename = (e, data) ->
- last_rollback = data.rlbk
node = data.rslt.obj
name = data.rslt.new_name
url = "#{base_url}/#{node.prop("id")}"
Spree.ajax
- type: "POST",
+ type: "PUT",
dataType: "json",
url: url,
data: {
- _method: "put",
"taxon[name]": name,
},
- error: handle_ajax_error
+ error: tree_error_handler(data)
handle_delete = (e, data) ->
- last_rollback = data.rlbk
node = data.rslt.obj
delete_url = "#{base_url}/#{node.prop("id")}"
- jConfirm Spree.translations.are_you_sure_delete, Spree.translations.confirm_delete, (r) ->
- if r
- Spree.ajax
- type: "POST",
- dataType: "json",
- url: delete_url.toString(),
- data: {
- _method: "delete",
- token: Spree.api_key
- },
- error: handle_ajax_error
- else
- $.jstree.rollback(last_rollback)
- last_rollback = null
-
-root = exports ? this
-root.setup_taxonomy_tree = (taxonomy_id) ->
+ if confirm(Spree.translations.are_you_sure_delete)
+ Spree.ajax
+ type: "DELETE",
+ dataType: "json",
+ url: delete_url,
+ error: tree_error_handler(data)
+ else
+ $.jstree.rollback(data.rlbk)
+
+@setup_taxonomy_tree = (taxonomy_id) ->
if taxonomy_id != undefined
# this is defined within admin/taxonomies/edit
- root.base_url = Spree.routes.taxonomy_taxons_path
+ base_url = Spree.routes.taxonomy_taxons_path
Spree.ajax
- url: Spree.url(base_url.path().replace("/taxons", "/jstree")).toString(),
+ url: base_url.replace("/taxons", "/jstree"),
success: (taxonomy) ->
last_rollback = null
@@ -90,6 +81,7 @@ root.setup_taxonomy_tree = (taxonomy_id) ->
json_data:
data: taxonomy,
ajax:
+ headers: { "X-Spree-Token": Spree.api_key }
url: (e) ->
"#{base_url}/#{e.prop('id')}/jstree"
themes:
@@ -126,11 +118,3 @@ root.setup_taxonomy_tree = (taxonomy_id) ->
.bind("rename.jstree", handle_rename)
.bind "loaded.jstree", ->
$(this).jstree("core").toggle_node($('.jstree-icon').first())
-
- $("#taxonomy_tree a").on "dblclick", (e) ->
- $("#taxonomy_tree").jstree("rename", this)
-
- # surpress form submit on enter/return
- $(document).keypress (e) ->
- if e.keyCode == 13
- e.preventDefault()
diff --git a/backend/app/assets/stylesheets/spree/backend.css b/backend/app/assets/stylesheets/spree/backend.css
index eeb84ea1520..611cc108170 100644
--- a/backend/app/assets/stylesheets/spree/backend.css
+++ b/backend/app/assets/stylesheets/spree/backend.css
@@ -3,8 +3,6 @@
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
- *= require jquery.alerts/jquery.alerts
- *= require jquery.alerts/jquery.alerts.spree
*= require responsive-tables
*= require normalize
*= require skeleton
diff --git a/backend/app/views/spree/admin/shared/_head.html.erb b/backend/app/views/spree/admin/shared/_head.html.erb
index e2331c5b764..a46e077ff71 100644
--- a/backend/app/views/spree/admin/shared/_head.html.erb
+++ b/backend/app/views/spree/admin/shared/_head.html.erb
@@ -21,7 +21,6 @@
<%= render "spree/admin/shared/translations" %>
<%= javascript_tag do -%>
- jQuery.alerts.dialogClass = 'spree';
var AUTH_TOKEN = "<%= form_authenticity_token %>";
Spree.api_key = "<%= try_spree_current_user.try(:spree_api_key) %>";
Spree.env = "<%= Rails.env %>";
diff --git a/backend/app/views/spree/admin/taxonomies/edit.erb b/backend/app/views/spree/admin/taxonomies/edit.erb
index 75d846e060d..34e1971936a 100755
--- a/backend/app/views/spree/admin/taxonomies/edit.erb
+++ b/backend/app/views/spree/admin/taxonomies/edit.erb
@@ -17,27 +17,23 @@
<%= form_for [:admin, @taxonomy] do |f| %>
+
+
+
+ <%= label_tag nil, Spree.t(:tree) %>
+
+
+
+
<%= Spree.t(:taxonomy_tree_instruction) %>
+
<% end %>
diff --git a/backend/lib/spree/backend/engine.rb b/backend/lib/spree/backend/engine.rb
index d627063d586..1f045082540 100644
--- a/backend/lib/spree/backend/engine.rb
+++ b/backend/lib/spree/backend/engine.rb
@@ -23,7 +23,6 @@ class Engine < ::Rails::Engine
jquery.jstree/themes/apple/*
fontawesome-webfont*
select2_locale*
- jquery.alerts/images/*
]
end
end
diff --git a/backend/spec/features/admin/taxons_spec.rb b/backend/spec/features/admin/taxons_spec.rb
index 1ad3532add1..64223709763 100644
--- a/backend/spec/features/admin/taxons_spec.rb
+++ b/backend/spec/features/admin/taxons_spec.rb
@@ -21,4 +21,11 @@
click_button "Update"
expect(page).to have_content("Taxon \"Shirt\" has been successfully updated!")
end
+
+ it "can see taxon tree", js: true do
+ taxonomy = create :taxonomy
+
+ visit spree.edit_admin_taxonomy_path(taxonomy)
+ expect(page).to have_content('Brand')
+ end
end
diff --git a/backend/vendor/assets/images/jquery.alerts/images/help.gif b/backend/vendor/assets/images/jquery.alerts/images/help.gif
deleted file mode 100755
index fbb5b329d4c..00000000000
Binary files a/backend/vendor/assets/images/jquery.alerts/images/help.gif and /dev/null differ
diff --git a/backend/vendor/assets/images/jquery.alerts/images/important.gif b/backend/vendor/assets/images/jquery.alerts/images/important.gif
deleted file mode 100755
index 654942362fc..00000000000
Binary files a/backend/vendor/assets/images/jquery.alerts/images/important.gif and /dev/null differ
diff --git a/backend/vendor/assets/images/jquery.alerts/images/info.gif b/backend/vendor/assets/images/jquery.alerts/images/info.gif
deleted file mode 100755
index 35e1dfa6c2c..00000000000
Binary files a/backend/vendor/assets/images/jquery.alerts/images/info.gif and /dev/null differ
diff --git a/backend/vendor/assets/images/jquery.alerts/images/title.gif b/backend/vendor/assets/images/jquery.alerts/images/title.gif
deleted file mode 100755
index 12253c7a44f..00000000000
Binary files a/backend/vendor/assets/images/jquery.alerts/images/title.gif and /dev/null differ
diff --git a/backend/vendor/assets/javascripts/jquery.alerts/jquery.alerts.js b/backend/vendor/assets/javascripts/jquery.alerts/jquery.alerts.js
deleted file mode 100755
index 80b1c85fb6c..00000000000
--- a/backend/vendor/assets/javascripts/jquery.alerts/jquery.alerts.js
+++ /dev/null
@@ -1,235 +0,0 @@
-// jQuery Alert Dialogs Plugin
-//
-// Version 1.1
-//
-// Cory S.N. LaViska
-// A Beautiful Site (http://abeautifulsite.net/)
-// 14 May 2009
-//
-// Visit http://abeautifulsite.net/notebook/87 for more information
-//
-// Usage:
-// jAlert( message, [title, callback] )
-// jConfirm( message, [title, callback] )
-// jPrompt( message, [value, title, callback] )
-//
-// History:
-//
-// 1.00 - Released (29 December 2008)
-//
-// 1.01 - Fixed bug where unbinding would destroy all resize events
-//
-// License:
-//
-// This plugin is dual-licensed under the GNU General Public License and the MIT License and
-// is copyright 2008 A Beautiful Site, LLC.
-//
-(function($) {
-
- $.alerts = {
-
- // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
-
- verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
- horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
- repositionOnResize: true, // re-centers the dialog on window resize
- overlayOpacity: .01, // transparency level of overlay
- overlayColor: '#FFF', // base color of overlay
- draggable: true, // make the dialogs draggable (requires UI Draggables plugin)
- okButton: ' OK ', // text for the OK button
- cancelButton: ' Cancel ', // text for the Cancel button
- dialogClass: null, // if specified, this class will be applied to all dialogs
-
- // Public methods
-
- alert: function(message, title, callback) {
- if( title == null ) title = 'Alert';
- $.alerts._show(title, message, null, 'alert', function(result) {
- if( callback ) callback(result);
- });
- },
-
- confirm: function(message, title, callback) {
- if( title == null ) title = 'Confirm';
- $.alerts._show(title, message, null, 'confirm', function(result) {
- if( callback ) callback(result);
- });
- },
-
- prompt: function(message, value, title, callback) {
- if( title == null ) title = 'Prompt';
- $.alerts._show(title, message, value, 'prompt', function(result) {
- if( callback ) callback(result);
- });
- },
-
- // Private methods
-
- _show: function(title, msg, value, type, callback) {
-
- $.alerts._hide();
- $.alerts._overlay('show');
-
- $("BODY").append(
- '');
-
- if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
-
- // IE6 Fix
- var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
-
- $("#popup_container").css({
- position: pos,
- zIndex: 99999,
- padding: 0,
- margin: 0
- });
-
- $("#popup_title").text(title);
- $("#popup_content").addClass(type);
- $("#popup_message").text(msg);
- $("#popup_message").html( $("#popup_message").text().replace(/\n/g, '
') );
-
- $("#popup_container").css({
- minWidth: $("#popup_container").outerWidth(),
- maxWidth: $("#popup_container").outerWidth()
- });
-
- $.alerts._reposition();
- $.alerts._maintainPosition(true);
-
- switch( type ) {
- case 'alert':
- $("#popup_message").after('');
- $("#popup_ok").click( function() {
- $.alerts._hide();
- callback(true);
- });
- $("#popup_ok").focus().keypress( function(e) {
- if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
- });
- break;
- case 'confirm':
- $("#popup_message").after('');
- $("#popup_ok").click( function() {
- $.alerts._hide();
- if( callback ) callback(true);
- });
- $("#popup_cancel").click( function() {
- $.alerts._hide();
- if( callback ) callback(false);
- });
- $("#popup_ok").focus();
- $("#popup_ok, #popup_cancel").keypress( function(e) {
- if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
- if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
- });
- break;
- case 'prompt':
- $("#popup_message").append('
').after('');
- $("#popup_prompt").width( $("#popup_message").width() );
- $("#popup_ok").click( function() {
- var val = $("#popup_prompt").val();
- $.alerts._hide();
- if( callback ) callback( val );
- });
- $("#popup_cancel").click( function() {
- $.alerts._hide();
- if( callback ) callback( null );
- });
- $("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
- if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
- if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
- });
- if( value ) $("#popup_prompt").val(value);
- $("#popup_prompt").focus().select();
- break;
- }
-
- // Make draggable
- if( $.alerts.draggable ) {
- try {
- $("#popup_container").draggable({ handle: $("#popup_title") });
- $("#popup_title").css({ cursor: 'move' });
- } catch(e) { /* requires jQuery UI draggables */ }
- }
- },
-
- _hide: function() {
- $("#popup_container").remove();
- $.alerts._overlay('hide');
- $.alerts._maintainPosition(false);
- },
-
- _overlay: function(status) {
- switch( status ) {
- case 'show':
- $.alerts._overlay('hide');
- $("BODY").append('');
- $("#popup_overlay").css({
- position: 'absolute',
- zIndex: 99998,
- top: '0px',
- left: '0px',
- width: '100%',
- height: $(document).height(),
- background: $.alerts.overlayColor,
- opacity: $.alerts.overlayOpacity
- });
- break;
- case 'hide':
- $("#popup_overlay").remove();
- break;
- }
- },
-
- _reposition: function() {
- var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
- var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
- if( top < 0 ) top = 0;
- if( left < 0 ) left = 0;
-
- // IE6 fix
- if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
-
- $("#popup_container").css({
- top: top + 'px',
- left: left + 'px'
- });
- $("#popup_overlay").height( $(document).height() );
- },
-
- _maintainPosition: function(status) {
- if( $.alerts.repositionOnResize ) {
- switch(status) {
- case true:
- $(window).bind('resize', $.alerts._reposition);
- break;
- case false:
- $(window).unbind('resize', $.alerts._reposition);
- break;
- }
- }
- }
-
- }
-
- // Shortuct functions
- jAlert = function(message, title, callback) {
- $.alerts.alert(message, title, callback);
- }
-
- jConfirm = function(message, title, callback) {
- $.alerts.confirm(message, title, callback);
- };
-
- jPrompt = function(message, value, title, callback) {
- $.alerts.prompt(message, value, title, callback);
- };
-
-})(jQuery);
\ No newline at end of file
diff --git a/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.css.erb b/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.css.erb
deleted file mode 100755
index 6eca847c454..00000000000
--- a/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.css.erb
+++ /dev/null
@@ -1,57 +0,0 @@
-#popup_container {
- font-family: Arial, sans-serif;
- font-size: 12px;
- min-width: 300px; /* Dialog will be no smaller than this */
- max-width: 600px; /* Dialog will wrap after this width */
- background: #FFF;
- border: solid 5px #999;
- color: #000;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- border-radius: 5px;
-}
-
-#popup_title {
- font-size: 14px;
- font-weight: bold;
- text-align: center;
- line-height: 1.75em;
- color: #666;
- background: #CCC url(<%= asset_path('jquery.alerts/images/title.gif') %>) top repeat-x;
- border: solid 1px #FFF;
- border-bottom: solid 1px #999;
- cursor: default;
- padding: 0em;
- margin: 0em;
-}
-
-#popup_content {
- background: 16px 16px no-repeat url(<%= asset_path('jquery.alerts/images/info.gif') %>);
- padding: 1em 1.75em;
- margin: 0em;
-}
-
-#popup_content.alert {
- background-image: url(<%= asset_path('jquery.alerts/images/info.gif') %>);
-}
-
-#popup_content.confirm {
- background-image: url(<%= asset_path('jquery.alerts/images/important.gif') %>);
-}
-
-#popup_content.prompt {
- background-image: url(<%= asset_path('jquery.alerts/images/help.gif') %>);
-}
-
-#popup_message {
- padding-left: 48px;
-}
-
-#popup_panel {
- text-align: center;
- margin: 1em 0em 0em 1em;
-}
-
-#popup_prompt {
- margin: .5em 0em;
-}
\ No newline at end of file
diff --git a/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.spree.css b/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.spree.css
deleted file mode 100644
index c4b8cb60d2f..00000000000
--- a/backend/vendor/assets/stylesheets/jquery.alerts/jquery.alerts.spree.css
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Spree Custom dialog styles */
-#popup_container.spree {
- color: #fff;
- background: #005294;
- border-color: #113F66;
-}
-
-#popup_container.spree #popup_title {
- color: #FFF;
- font-weight: normal;
- text-align: left;
- background: #76A5CC;
- border: solid 1px #005294;
- padding-left: 1em;
-}
-
-#popup_container.spree #popup_content {
- background: none;
-}
-
-#popup_container.spree #popup_message {
- padding-left: 0em;
-}
-
-#popup_container.spree input[type='button'] {
- border: outset 2px #76A5CC;
- color: #fff;
- background: #3778AE;
-}