Skip to content

Commit

Permalink
use webpacker
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Aug 25, 2019
1 parent 399a54c commit 9a62f0c
Show file tree
Hide file tree
Showing 20 changed files with 1,303 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gem 'enju_leaf', github: 'next-l/enju_leaf'
gem 'enju_library', github: 'next-l/enju_library'
gem 'enju_biblio', github: 'next-l/enju_biblio'
gem 'sassc-rails'
gem 'webpacker'
group :test do
gem 'rails-controller-testing'
gem 'rspec_junit_formatter'
Expand Down
19 changes: 19 additions & 0 deletions spec/dummy/app/javascript/packs/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'jquery/src/jquery'
import 'jquery-migrate/dist/jquery-migrate'
import 'jquery-ui/core'
import 'jquery-ui/widget'
import 'jquery-ui/menu'
import 'jquery-ui/mouse'
import 'jquery-ui/position'
import 'jquery-ui/sortable'
import 'jquery-ui/tabs'
import 'jquery-ui/datepicker'
import 'jquery-colorbox/jquery.colorbox'
import 'jquery-powertip/dist/jquery.powertip'
import '../src/jquery.ui.menubar'
import '../src/jquery.cookie'
import '../src/jquery.highlight'
import '../src/jquery.shortcut'
import '../src/enju_leaf/menu'
import '../src/enju_leaf/portlets'
import '../src/enju_leaf/select_locale'
Empty file.
30 changes: 30 additions & 0 deletions spec/dummy/app/javascript/src/enju_leaf/autocomplete_agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$(document).ready(function(){
$("#creator_form").on('cocoon:after-insert', function(e, added_task){
$('.creator_full_name').focus(function(){
$(this).autocomplete({
minLength: 1,
//source: '/agents.json'
source: function(request, response){
$.ajax({
url: '/agents.json',
datatype: 'json',
data: {
query: request.term + '*'
},
success: function(data) {
response(data);
}
});
},
select: function(event, ui){
//console.log(added_task[0].getElementsByTagName('input')[0]);
added_task[0].getElementsByTagName('input')[0].value = ui.item.agent_id;
}
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo(ul);
};
});
});
});
15 changes: 15 additions & 0 deletions spec/dummy/app/javascript/src/enju_leaf/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
document.documentElement.className = 'hidden';

$(function(){
$('#bar1').menubar({
position:{
within: $("#demo-frame").add(window).first()
}
});
$('.hidden').removeClass('hidden');
});

$(document).ready(function(){
$("#tabs").tabs();
$('.hidden').removeClass('hidden');
});
5 changes: 5 additions & 0 deletions spec/dummy/app/javascript/src/enju_leaf/mobile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//= require rails-ujs
//= require jquery/dist/jquery
//= require jquery-migrate/dist/jquery-migrate
//= require jquery.mobile-1.4.5
//= require jquery-colorbox/jquery.colorbox
63 changes: 63 additions & 0 deletions spec/dummy/app/javascript/src/enju_leaf/portlets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// The following code was originally written by Ralph Bean. Thanks Ralph!
// http://groups.google.com/group/jquery-ui/msg/f11601f56737a129

function saveOrder(year, month, day, root_path) {
$(".column").each(function(index, value){
var columnId = value.id;
var cookieName = "listOrder" + columnId;
// Get the order for this column.
var order = $('#' + columnId).sortable("toArray");
// For each portlet in the column
for ( var i = 0, n = order.length; i < n; i++ ) {
var v = $('#' + order[i] ).find('.portlet-content').is(':visible');
// Modify the array we're saving to indicate what's open and
// what's not.
order[i] = order[i] + ":" + v;
}
$.cookie(cookieName, order, { path: root_path, expiry: new Date(year, month, day)});
});
}

// function that restores the list order from a cookie
function restoreOrder() {
$(".column").each(function(index, value) {
var columnId = value.id;
var cookieName = "listOrder" + columnId;
var cookie = $.cookie(cookieName);
if ( cookie == null ) { return; }
var IDs = cookie.split(",");
for (var i = 0, n = IDs.length; i < n; i++ ) {
var toks = IDs[i].split(":");
if ( toks.length != 2 ) {
continue;
}
var portletId = toks[0];
var visible = toks[1];
var portlet = $(".column")
.find('#' + portletId)
.appendTo($('#' + columnId));
if (visible === 'false') {
portlet.find(".ui-icon").toggleClass("ui-icon-minus");
portlet.find(".ui-icon").toggleClass("ui-icon-plus");
portlet.find(".portlet-content").hide();
}
}
});
}

$(document).ready( function () {
$(".column").sortable({
connectWith: ['.column'],
stop: function() { saveOrder(); }
});

$(".portlet")
.addClass("ui-widget ui-widget-content")
.addClass("ui-helper-clearfix ui-corner-all")
.find(".portlet-header")
.addClass("ui-widget-header ui-corner-all")
.prepend('<span class="ui-icon ui-icon-minus"></span>')
.end()
.find(".portlet-content");
});

9 changes: 9 additions & 0 deletions spec/dummy/app/javascript/src/enju_leaf/select_locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$(function(){
$("body").click(function(event){
$("#select_locale").hide();
});
$("#select_locale_menu").click(function(event){
$("#select_locale").toggle();
event.stopPropagation();
});
});
117 changes: 117 additions & 0 deletions spec/dummy/app/javascript/src/jquery.cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {

var pluses = /\+/g;

function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}

function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}

function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}

function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}

function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}

var config = $.cookie = function (key, value, options) {

// Write

if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);

if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}

return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}

// Read

var result = key ? undefined : {};

// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];

for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');

if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}

// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}

return result;
};

config.defaults = {};

$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}

// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};

}));
Loading

0 comments on commit 9a62f0c

Please sign in to comment.