ksk 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ class Kiosk::NavigationsController < Bhf::ApplicationController
2
+
3
+ def sort
4
+ Navigation.sort_items(params[:navigation])
5
+ Navigation.find(params[:id]).update_attribute(:parent_id, params[:parent_id])
6
+ head :ok
7
+ end
8
+
9
+ def create
10
+ n = Navigation.new(params[:navigation])
11
+ n.save
12
+ render :text => n.id
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,65 @@
1
+ module Kiosk
2
+ module ApplicationHelper
3
+
4
+ def recursive_navi(navis, current_level = 0, max_level = 99)
5
+ a = ' <ul>'
6
+ navis.each do |navi|
7
+ active = navi.slug == @slugs[current_level] ? ' class="active"' : nil
8
+ next unless nt = navi.navigation_type
9
+ link = if nt.name == 'news'
10
+ link_to navi.title, posts_path
11
+ else
12
+ link_to navi.title, navi.link
13
+ end
14
+ a += " <li#{active}>#{link}"
15
+ if active && current_level <= max_level && navi.children.not_hidden.any?
16
+ a += recursive_navi(navi.children.not_hidden, current_level+1, max_level)
17
+ end
18
+ a += '</li> '
19
+ end
20
+ a += '</ul> '
21
+ end
22
+
23
+ def md(text)
24
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(), fenced_code_blocks: true, autolink: true)
25
+ markdown.render(text).html_safe
26
+ end
27
+
28
+ def mdap(text, images, data_files)
29
+ t = place_images(text, images)
30
+ t = place_data_files(t, data_files)
31
+ md(t)
32
+ end
33
+
34
+ def place_content(text, files, type, &html)
35
+ t = text
36
+ (text || '').scan(Apdown.parse_regex(type)).each do |match|
37
+ if asset = files[match[1].to_i-1]
38
+ t = t.gsub(match[0], html.call(asset, match[2]))
39
+ end
40
+ end
41
+ t.html_safe
42
+ end
43
+
44
+ def place_images(text, images)
45
+ place_content(text, images, 'img') do |asset, option|
46
+ c = option || 'thumb'
47
+ image_tag asset.file.url(c), class: ['uploaded_image', c]
48
+ end
49
+ end
50
+
51
+ def place_data_files(text, data_files)
52
+ place_content(text, data_files, 'file') do |asset, option|
53
+ link_to asset.file.url, class: asset.has_preview? ? :uploaded_file_preview : :uploaded_file do
54
+ if asset.has_preview?
55
+ image_tag( asset.preview_file.url(:banner) )+
56
+ '<span>Hier klicken um die Datei herunter zu laden</span>'.html_safe
57
+ else
58
+ asset.file_file_name
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,15 @@
1
+ - data_source ||= field.reflection.klass.all
2
+ - fk = field.reflection.foreign_key
3
+ .node
4
+ .label= f.label fk
5
+ .input
6
+ = f.select fk, options_from_collection_for_select(data_source, :id, :to_bhf_s, f.object.send(fk))#, include_blank: true
7
+ = render partial: 'bhf/helper/field_errors', locals: {f: f, field: fk}
8
+
9
+ :javascript
10
+ window.addEvent('domready', function(){
11
+ var x = function(e){
12
+ $('post_event_id').getParent('.node').toggleClass('hide', this.value !== '2');
13
+ };
14
+ x.call($('post_category_id').addEvent('change', x));
15
+ });
@@ -0,0 +1,6 @@
1
+ = node f, field do
2
+ - if f.object.file.file?
3
+ - if f.object.is_image?
4
+ = image_tag f.object.file.url(:thumb), class: :uploaded_image
5
+ - else
6
+ = link_to f.object.file_file_name, f.object.file.url, class: :uploaded_file
@@ -0,0 +1,10 @@
1
+ = node f, field do
2
+ - if f.object.photo.file?
3
+ - if false
4
+ = image_tag f.object.photo.url, class: 'uploaded_image'
5
+ - else
6
+ = link_to file, file, class: 'uploaded_file'
7
+ .file_delete
8
+ = f.check_box :delete_photo
9
+ = f.label :delete_photo, t('bhf.helpers.file.delete')
10
+ = f.file_field field.name
@@ -0,0 +1,11 @@
1
+ - data_source = Asset.only_data_files
2
+ - fk = :asset_id
3
+ - if params[:asset_id]
4
+ - f.object.asset_id = params[:asset_id]
5
+ = f.hidden_field fk
6
+ - else
7
+ .node
8
+ .label= f.label fk
9
+ .input
10
+ = f.select fk, options_from_collection_for_select(data_source, :id, :to_bhf_s, f.object.send(fk)), include_blank: true
11
+ = render partial: 'bhf/helper/field_errors', locals: {f: f, field: fk}
@@ -0,0 +1,35 @@
1
+ - if f.object.assets.any?
2
+ = node f, field do
3
+ - f.object.assets.each do |asset|
4
+ = f.fields_for field.name, asset do |a|
5
+ - if asset.file.file?
6
+ - if asset.is_image?
7
+ = image_tag asset.file.url(:medium), class: :uploaded_image
8
+ - else
9
+ = link_to asset.file_file_name, asset.file.url, class: :uploaded_file
10
+
11
+ .file_delete
12
+ = a.check_box :_destroy
13
+ = a.label :_destroy, t('bhf.helpers.file.delete')
14
+ %hr
15
+
16
+ = node f, field do
17
+ .array_holder
18
+ = f.fields_for field.name, Asset.new do |a|
19
+ = a.file_field :file
20
+
21
+
22
+ -#
23
+ new Sortables(sortableElems, {
24
+ handle: '.handle',
25
+ onStart: function(element, clone){
26
+ element.addClass('dragged');
27
+ },
28
+ onComplete: function(element){
29
+ element.removeClass('dragged');
30
+ new Request({
31
+ method: 'put',
32
+ url: this.element.getParent('tbody').get('data-sort-url')
33
+ }).send({data: {order: this.serialize()}});
34
+ }
35
+ });
@@ -0,0 +1,37 @@
1
+ - if f.object.assets.any?
2
+ = node f, field do
3
+ %h3 Bilder:
4
+ %ol.assets_list{:'data-sort-url' => sort_bhf_entries_path('assets')}
5
+ - f.object.assets.only_images.each do |asset|
6
+ %li{id: "#{asset.id}_images"}
7
+ = render partial: 'bhf/entries/form/has_many/upload', locals: {field: field, f: f, asset: asset}
8
+
9
+ %h3 Dateien:
10
+ %ol.assets_list{:'data-sort-url' => sort_bhf_entries_path('assets')}
11
+ - f.object.assets.only_data_files.each do |asset|
12
+ %li{id: "#{asset.id}_data_files"}
13
+ = render partial: 'bhf/entries/form/has_many/upload', locals: {field: field, f: f, asset: asset}
14
+
15
+ = node f, field do
16
+ .array_holder
17
+ = f.fields_for field.name, Asset.new do |a|
18
+ = a.file_field :file
19
+
20
+
21
+ :javascript
22
+ $$('.assets_list').each(function(x){
23
+ new Sortables(x, {
24
+ handle: '.handle',
25
+ onStart: function(element, clone){
26
+ element.addClass('dragged');
27
+ },
28
+ onComplete: function(element){
29
+ element.removeClass('dragged');
30
+ new Request({
31
+ method: 'put',
32
+ url: this.element.getParent('ol').get('data-sort-url')
33
+ }).send({data: {order: this.serialize()}});
34
+ }
35
+ });
36
+
37
+ });
@@ -0,0 +1,19 @@
1
+ = f.fields_for field.name, asset do |a|
2
+ - if asset.file.file?
3
+ .position_handle.float_left x
4
+ - if asset.is_image?
5
+ = image_tag asset.file.url(:medium), class: 'uploaded_image float_left'
6
+ - else
7
+ = link_to asset.file_file_name, asset.file.url, class: 'uploaded_image float_left'
8
+ - if asset.has_preview?
9
+ = link_to edit_bhf_entry_path('previews', asset.preview), class: 'float_left' do
10
+ = image_tag asset.preview_file.url(:thumb), class: 'uploaded_image'
11
+ - else
12
+ = link_to 'Vorschaubild hochladen', new_bhf_entry_path('previews', asset_id: asset.id), class: 'float_left'
13
+
14
+ .file_delete.float_right
15
+ = a.check_box :_destroy
16
+ = a.label :_destroy, t('bhf.helpers.file.delete')
17
+
18
+
19
+ %hr
@@ -0,0 +1,59 @@
1
+ :ruby
2
+ def p_recursive_navi(navis, current_level = 0, max_level = 99, ul = 'ul', first_wrap = '')
3
+ a = "\n <#{ul}#{first_wrap}>\n"
4
+ navis.each do |navi|
5
+ x = link_to 'edit', edit_bhf_entry_path('navigation', navi)
6
+ y = link_to 'delete', bhf_entry_path('navigation', navi), :method => :delete, :confirm => t('bhf.helpers.promts.confirm')
7
+ a += " <li id='navigation_#{navi.id}'><div><span class='title'>#{navi.title}</span> <span class='links'>#{x} #{y}</span></div>"
8
+ if current_level <= max_level and navi.children.any?
9
+ a += p_recursive_navi(navi.children, current_level+1, max_level, ul)
10
+ end
11
+ a += "</li> "
12
+ end
13
+ a += "</#{ul}> "
14
+ end
15
+
16
+
17
+ #content.navi
18
+ = p_recursive_navi(Navigation.top_level, 0, 99, 'ol', ' id="tree" class="multi_grid"').html_safe
19
+
20
+
21
+ = javascript_include_tag 'kiosk/classes/NaviAdmin'
22
+ :javascript
23
+ var naviA = new NaviAdmin({
24
+ elemTree: $('tree'),
25
+ onItemDropped: function(item, parent, itemId, parentId){
26
+ var queryParams = {
27
+ '_method': 'put',
28
+ id: itemId,
29
+ parent_id: parentId
30
+ };
31
+ queryParams[this.getNaviName()] = this.getIdPositions();
32
+
33
+ new Request({
34
+ url: '#{sort_kiosk_navigations_path}'
35
+ }).post(queryParams);
36
+ }
37
+ });
38
+ $$('#navigation_platform .create a').addEvent('click', function(e){
39
+ e.preventDefault();
40
+ var name = prompt('Name', '');
41
+ if ( ! name) { return; }
42
+
43
+ var naviName = naviA.getNaviName();
44
+ var queryParams = {};
45
+ queryParams[naviName] = {
46
+ title: name
47
+ };
48
+ new Request({
49
+ url: '#{kiosk_navigations_path}',
50
+ onSuccess: function(responseText){
51
+ new Element('li', {
52
+ 'id': naviName+'_'+responseText,
53
+ 'html': '<div> <span class="title">'+name+'</span> <span class="links">#{link_to 'edit', edit_bhf_entry_path('navigation', 'NAVIID')} #{link_to 'delete', bhf_entry_path('navigation', 'NAVIID'), method: :delete, data: {confirm: t('bhf.helpers.promts.confirm')}}</span></div>'.replace(/NAVIID/g, responseText)
54
+ })
55
+ .inject($('tree').getElement('li'), 'before');
56
+ naviA.reInit();
57
+ }
58
+ }).post(queryParams);
59
+ });
@@ -0,0 +1,2 @@
1
+ = link_to object.send(column.name), title: object.send(column.name), target: '_blank' do
2
+ %strong Link ⬀
@@ -0,0 +1,2 @@
1
+ de:
2
+ kiosk: a
@@ -0,0 +1,2 @@
1
+ en:
2
+ kiosk: a
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ unless Bhf::Engine.config.remove_default_routes
2
+ Rails.application.routes.draw(&Kiosk::Engine.config.routes)
3
+ end
@@ -0,0 +1,60 @@
1
+ module Kiosk
2
+ module Asset
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'assets'
7
+
8
+ belongs_to :fileable, polymorphic: true
9
+
10
+ default_scope order: 'position ASC, created_at DESC'
11
+
12
+ has_one :preview
13
+ before_create :set_last_position
14
+
15
+
16
+ #validates_attachment :file, :content_type => { :content_type => IMGTYPE }
17
+ IMGTYPE = ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif']
18
+
19
+ scope :only_images, where(file_content_type: IMGTYPE)
20
+ scope :first_image, only_images.limit(1)
21
+ scope :other_images, only_images.offset(1)
22
+
23
+ scope :only_data_files, where(['file_content_type not in (?)', IMGTYPE])
24
+ scope :first_data_files, only_data_files.limit(1)
25
+
26
+ before_file_post_process :allow_only_images
27
+ end
28
+
29
+
30
+ def allow_only_images
31
+ if !(file.content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$})
32
+ return false
33
+ end
34
+ end
35
+
36
+ def is_image?
37
+ IMGTYPE.include?(file.content_type)
38
+ end
39
+
40
+ def has_preview?
41
+ preview && preview.assets.any?
42
+ end
43
+
44
+ def preview_file
45
+ if has_preview?
46
+ preview.assets.first.file
47
+ end
48
+ end
49
+
50
+ def to_bhf_s
51
+ "ID: #{id} - Name: #{file_file_name}"
52
+ end
53
+
54
+ def set_last_position
55
+ self.position = self.class.where(fileable_id: self.fileable_id).count+1
56
+ end
57
+
58
+ end
59
+ end
60
+
@@ -0,0 +1,13 @@
1
+ module Kiosk
2
+ module Category
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'categories'
7
+ has_many :posts
8
+
9
+ validates_length_of :title, :minimum => 3
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,70 @@
1
+ # encoding: UTF-8
2
+ module Kiosk
3
+ module Navigation
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ self.table_name = 'navigations'
8
+ validates_uniqueness_of :slug
9
+ validates_presence_of :static
10
+
11
+ before_validation :static_setter
12
+
13
+ default_scope :order => 'position ASC, created_at DESC'
14
+
15
+ belongs_to :static
16
+ belongs_to :navigation_type
17
+ belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Navigation'
18
+ has_many :children, :foreign_key => 'parent_id', :class_name => 'Navigation', :dependent => :delete_all
19
+
20
+ scope :top_level, where(parent_id: 0)
21
+
22
+ scope :not_hidden, where(hidden: false)
23
+
24
+ before_save :set_slug, :set_link
25
+ end
26
+
27
+
28
+ def set_slug
29
+ return if !slug.blank?
30
+ write_attribute(:slug, title.to_url)
31
+ end
32
+
33
+ def static_setter
34
+ write_attribute(:static_id, (self.static && self.static.id) || ::Static.all.first.id)
35
+ end
36
+
37
+ def set_link
38
+ write_attribute(:link, get_link)
39
+ end
40
+
41
+ def get_link(x = '')
42
+ a = '/'+slug+x
43
+ if parent
44
+ a = parent.get_link(a)
45
+ end
46
+ a
47
+ end
48
+
49
+ module ClassMethods
50
+ def sort_items(ids)
51
+ ids.each_pair do |i, id|
52
+ find(id).update_attribute(:position, i.to_i)
53
+ end
54
+ end
55
+
56
+ def show_bread_crum_desc(navi)
57
+ a = [navi]
58
+ if navi.parent
59
+ a << show_bread_crum_desc(navi.parent)
60
+ end
61
+ a.flatten
62
+ end
63
+
64
+ def show_bread_crum(navi)
65
+ show_bread_crum_desc(navi).reverse
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,11 @@
1
+ module Kiosk
2
+ module NavigationType
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'navigation_types'
7
+ has_many :navigations
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,57 @@
1
+ module Kiosk
2
+ module Post
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'posts'
7
+
8
+ include Apdown
9
+
10
+ belongs_to :category
11
+ belongs_to :event
12
+ has_many :assets, as: :fileable
13
+ accepts_nested_attributes_for :assets, allow_destroy: true
14
+
15
+ default_scope order: 'created_at DESC'
16
+ default_scope where(published: true)
17
+
18
+ scope :all_posts, except(:where)
19
+ scope :top, where(top_news: true)
20
+
21
+ validates_length_of :headline, minimum: 3
22
+ validates_length_of :content, minimum: 10, maximum: 5000
23
+
24
+ end
25
+
26
+
27
+ def apdown_text
28
+ content
29
+ end
30
+
31
+ def content_long
32
+ "#{intro} #{hidden_text}"
33
+ end
34
+
35
+ def content_short
36
+ intro
37
+ end
38
+
39
+ def intro
40
+ split_content[0]
41
+ end
42
+
43
+ def hidden_text
44
+ split_content[1]
45
+ end
46
+
47
+ def split_content
48
+ return [] if read_attribute(:content).blank?
49
+ read_attribute(:content).split('@@@')
50
+ end
51
+
52
+ def content_has_more?
53
+ !hidden_text.blank?
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,23 @@
1
+ module Kiosk
2
+ module Preview
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'previews'
7
+
8
+ belongs_to :asset
9
+ has_many :assets, :as => :fileable
10
+
11
+ accepts_nested_attributes_for :assets, allow_destroy: true
12
+
13
+ validates_presence_of :asset_id
14
+ end
15
+
16
+
17
+ def file_assets
18
+ assets.only_data_files
19
+ end
20
+
21
+
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ module Kiosk
2
+ module Static
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ self.table_name = 'statics'
7
+
8
+ include Apdown
9
+
10
+ has_one :navigation
11
+ has_many :assets, :as => :fileable
12
+
13
+ accepts_nested_attributes_for :assets, allow_destroy: true
14
+ end
15
+
16
+ end
17
+ end
data/lib/apdown.rb ADDED
@@ -0,0 +1,42 @@
1
+ module Apdown
2
+
3
+ def self.parse_regex(type)
4
+ /(\{#{type}_(\d{1,2})_?(\w+)?\})/i
5
+ end
6
+
7
+ def text_used_content(type)
8
+ (apdown_text || '').scan(Apdown.parse_regex(type)).each_with_object([]) do |match, used_numbers|
9
+ used_numbers << match[1].to_i
10
+ end
11
+ end
12
+
13
+ def text_unused_content(all_files, type, preselected = [])
14
+ all_numbers = []
15
+ all_files.each_with_index { |a, i| all_numbers << i+1 }
16
+
17
+ unused_numbers = all_numbers - (text_used_content(type)+preselected)
18
+
19
+ unused_files = []
20
+ all_files.each_with_index do |a, i|
21
+ unused_files << a if unused_numbers.include?(i+1)
22
+ end
23
+ unused_files
24
+ end
25
+
26
+ def text_used_images
27
+ text_used_content('img')
28
+ end
29
+
30
+ def text_unused_images
31
+ text_unused_content(assets.only_images, 'img', respond_to?(:apdown_preselect) && apdown_preselect || [])
32
+ end
33
+
34
+ def text_used_data_files
35
+ text_used_content('file')
36
+ end
37
+
38
+ def text_unused_data_files
39
+ text_unused_content(assets.only_data_files, 'file')
40
+ end
41
+
42
+ end
data/lib/kiosk.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'stringex'
2
+
3
+ module Kiosk
4
+ class Engine < Rails::Engine
5
+
6
+ config.css << 'kiosk/application'
7
+
8
+ config.navigation_routes = lambda {
9
+ namespace :kiosk, path: Bhf::Engine.config.mount_at do
10
+ resources :navigations, only: [:create] do
11
+ put :sort, on: :collection
12
+ end
13
+ end
14
+ }
15
+
16
+ end
17
+ end
18
+
19
+ require 'apdown'
20
+ require 'actives/asset'
21
+ require 'actives/category'
22
+ require 'actives/navigation'
23
+ require 'actives/navigation_type'
24
+ require 'actives/post'
25
+ require 'actives/preview'
26
+ require 'actives/static'
@@ -0,0 +1,7 @@
1
+ module Kiosk
2
+ class Engine < Rails::Engine
3
+
4
+ # config.test = 1
5
+
6
+ end
7
+ end
@@ -0,0 +1,184 @@
1
+ /*
2
+ ---
3
+
4
+ script: class.NaviAdmin.js
5
+
6
+ description: Class for creating a drag and drop sorting and nesting items interface for lists of items.
7
+
8
+ license: MIT-style license
9
+
10
+ authors:
11
+ - Anton Pawlik
12
+
13
+ requires:
14
+ - /Drag.Move
15
+
16
+ ...
17
+ */
18
+ var NaviAdmin = new Class({
19
+
20
+ Implements: [Options, Events],
21
+
22
+ options: {/*
23
+ onItemDropped: $empty(item, parent, itemId, parentId),*/
24
+ elemTree: null,
25
+ dragSpan: new Element('span', {'class': 'drag'}),
26
+ pos_helper: new Element('li', {'class': 'pos_helper'})
27
+ },
28
+
29
+ version: '0.2',
30
+ elemTree: null,
31
+ lis: [],
32
+ droppablePlaceholder: [],
33
+ drag: null,
34
+ hoverElem: null,
35
+
36
+ initialize: function(_options){
37
+ var opts = ($type(_options) != 'object' ? {'elemTree': _options} : _options);
38
+ if (!$defined(opts.elemTree)) { alert('NaviAdmin - no object'); return; }
39
+ this.setOptions(opts);
40
+
41
+ this.elemTree = this.options.elemTree;
42
+
43
+ this.removeListener();
44
+ this.createPosHelper();
45
+
46
+ this.lis.each(function(elem){
47
+ this.options.dragSpan.clone()
48
+ .inject(elem.getElement('div'), 'top')
49
+ .addEvent('mouseup', this.disableUp.bind(this))
50
+ .addEvent('mousedown', this.initDrag.bind(this));
51
+ }.bind(this));
52
+ },
53
+
54
+ disableUp: function(e){
55
+ this.drag.stop(e);
56
+ this.liDropped(e.target.getParent('li'), this.hoverElem);
57
+ },
58
+
59
+ removeListener: function(){
60
+ this.elemTree.getElements('.pos_helper').dispose();
61
+ this.elemTree.getElements('.drag').dispose();
62
+ },
63
+
64
+ createPosHelper: function(){
65
+ this.hoverElem = null;
66
+
67
+ this.lis = this.elemTree.getElements('li').addClass('item');
68
+
69
+ this.elemTree.getElements('.pos_helper').dispose();
70
+
71
+ this.droppablePlaceholder = [];
72
+ this.lis.each(function(elem){
73
+ this.droppablePlaceholder.push(
74
+ this.options.pos_helper.clone().inject(elem, 'after')
75
+ );
76
+ }.bind(this));
77
+
78
+ this.elemTree.getElements('ol').concat(this.elemTree).each(function(elem){
79
+ this.droppablePlaceholder.push(
80
+ this.options.pos_helper.clone().inject(elem, 'top')
81
+ );
82
+ }.bind(this));
83
+ },
84
+
85
+ initDrag: function(event){
86
+ var current_li = event.target.getParent('li');
87
+ var dropAndMoveAsChild = [];
88
+ this.lis.each(function(li){
89
+ if (current_li !== li) dropAndMoveAsChild.push(li);
90
+ });
91
+
92
+ this.drag = new Drag.Move(current_li, {
93
+ handle: event.target,
94
+ droppables: dropAndMoveAsChild.concat(this.droppablePlaceholder),
95
+ onStart: function(element, hoverElement){
96
+ element
97
+ .addClass('moved')
98
+ .getNext('li').dispose();
99
+ },
100
+ onEnter: function(element, hoverElement){
101
+ hoverElement.addClass('hover');
102
+ this.hoverElem = hoverElement;
103
+ }.bind(this),
104
+ onLeave: function(element, hoverElement){
105
+ hoverElement.removeClass('hover');
106
+ }
107
+ });
108
+ this.elemTree.addClass('drag_active');
109
+ this.drag.start(event);
110
+ },
111
+
112
+ liDropped: function(element, hoverElement){
113
+ this.elemTree.removeClass('drag_active');
114
+ this.drag.detach();
115
+
116
+ if (hoverElement) {
117
+ var parentLiId, parentLi, ol;
118
+ var li = element.erase('style').removeClass('moved').dispose();
119
+
120
+ if (hoverElement.hasClass('pos_helper')) {
121
+ parentLi = hoverElement.getParent('li');
122
+ parentLiId = (parentLi) ? this.getId(parentLi.get('id')).id : 0;
123
+
124
+ li.inject(hoverElement, 'after');
125
+ }
126
+ else {
127
+ ol = hoverElement.getElement('ol');
128
+ if( ! ol){
129
+ ol = new Element('ol').inject(hoverElement);
130
+ }
131
+ li.inject(ol);
132
+
133
+ parentLiId = this.getId(hoverElement.get('id')).id;
134
+ }
135
+
136
+ this.fireEvent('itemDropped', [
137
+ li, hoverElement,
138
+ this.getId(li.get('id')).id,
139
+ parentLiId
140
+ ]);
141
+
142
+ hoverElement.removeClass('hover');
143
+ }
144
+ else {
145
+ element.erase('style').removeClass('moved');
146
+ }
147
+ this.createPosHelper();
148
+ },
149
+ getId: function(str){
150
+ var nameId;
151
+ var output = {'name': null, 'id': null};
152
+
153
+ if ( ! str) return output;
154
+
155
+ nameId = str.match(/(.+)[-=_](.+)/);
156
+ if ( ! nameId) return output;
157
+
158
+ output.name = nameId[1];
159
+ output.id = nameId[2];
160
+
161
+ return output;
162
+ },
163
+
164
+ getNaviName: function(){
165
+ return this.getId(
166
+ this.elemTree.getElement('li.item').get('id')
167
+ ).name || 'navigation';
168
+ },
169
+
170
+ getIdPositions: function(){
171
+ var idsPosition = [];
172
+ this.elemTree.getElements('li.item').each(function(el) {
173
+ var nameId = this.getId(el.get('id'));
174
+ if (nameId) {
175
+ idsPosition.push(nameId.id);
176
+ }
177
+ }.bind(this));
178
+ return idsPosition;
179
+ },
180
+
181
+ reInit: function(){
182
+ this.initialize(this.options);
183
+ }
184
+ });
@@ -0,0 +1,94 @@
1
+ .navi
2
+ /* STYLING */
3
+ .multi_grid
4
+ border: 1px solid #CDD0D3
5
+ border-bottom: 0
6
+ border: 1px solid #CDD0D3
7
+
8
+ li
9
+ margin: 0
10
+ display: block
11
+ padding: 5px 0 5px 10px
12
+ border-bottom: 1px solid #CDD0D3
13
+
14
+
15
+
16
+ li div
17
+ border-bottom: 1px solid #CDD0D3
18
+ padding-bottom: 5px
19
+ clear: both
20
+ overflow: hidden
21
+
22
+ li .title
23
+ float: left
24
+
25
+ li .links
26
+ float: right
27
+
28
+ li
29
+ padding-left: 30px
30
+ border-bottom: 0
31
+
32
+ .moved
33
+ background-color: rgba(255, 255, 255, 0.6)
34
+ padding-right: 20px
35
+ min-width: 400px
36
+
37
+ .drag
38
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAOCAYAAADwikbvAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QTgxODI2NTlBNUY5MTFERkJEQTY5NjM0QTI0OTkzQ0MiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QTgxODI2NUFBNUY5MTFERkJEQTY5NjM0QTI0OTkzQ0MiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBODE4MjY1N0E1RjkxMURGQkRBNjk2MzRBMjQ5OTNDQyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBODE4MjY1OEE1RjkxMURGQkRBNjk2MzRBMjQ5OTNDQyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlrgasEAAAA7SURBVHjaYvz//z8DuYCJgQKAUzOLSOV/ZJpUmy3RaJI0H0ej6WQzMBYGyGaYjUguGC6hzThgaRsgwABmFBehNiE89QAAAABJRU5ErkJggg==) no-repeat 0px 2px
39
+
40
+ /* ESSENTIAL */
41
+ .drag
42
+ display: block
43
+ float: left
44
+ height: 20px
45
+ width: 18px
46
+ cursor: move
47
+ background: gray
48
+
49
+ .multi_grid,
50
+ .multi_grid ol
51
+ list-style: none
52
+
53
+ .multi_grid
54
+ li div
55
+ clear: both
56
+ overflow: hidden
57
+
58
+ .pos_helper
59
+ padding: 0
60
+ margin: 0
61
+ height: 0
62
+ transition-duration: 0.3s
63
+ -moz-transition-duration: 0.3s
64
+ -webkit-transition-duration: 0.3s
65
+
66
+ &.drag_active .pos_helper
67
+ height: 6px
68
+
69
+ .pos_helper.hover
70
+ height: 20px
71
+
72
+ .hover
73
+ background-color: rgba(255, 0, 0, 0.1)
74
+ transition-duration: 0.3s
75
+ -moz-transition-duration: 0.3s
76
+ -webkit-transition-duration: 0.3s
77
+
78
+ .moved
79
+ z-index: 3000
80
+
81
+
82
+ .float_left
83
+ float: left
84
+ margin-right: 100px !important
85
+ .float_right
86
+ float: right
87
+
88
+ .position_handle
89
+ background: url(../bhf/pictos.png) no-repeat -94px 0
90
+ cursor: move
91
+ display: block
92
+ text-indent: -9999px
93
+ height: 30px
94
+ width: 30px
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ksk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anton Pawlik
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bhf
16
+ requirement: &70307840952220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.30
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70307840952220
25
+ - !ruby/object:Gem::Dependency
26
+ name: stringex
27
+ requirement: &70307840951620 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70307840951620
36
+ description: Fast and friendly
37
+ email: anton.pawlik@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files:
41
+ - README.md
42
+ files:
43
+ - app/controllers/kiosk/navigations_controller.rb
44
+ - app/helpers/kiosk/application_helper.rb
45
+ - app/views/bhf/entries/form/belongs_to/_category.html.haml
46
+ - app/views/bhf/entries/form/column/_image.html.haml
47
+ - app/views/bhf/entries/form/column/_s3_file.html.haml
48
+ - app/views/bhf/entries/form/column/_select_file_assets.html.haml
49
+ - app/views/bhf/entries/form/has_many/__assets.html.haml
50
+ - app/views/bhf/entries/form/has_many/_assets.html.haml
51
+ - app/views/bhf/entries/form/has_many/_upload.html.haml
52
+ - app/views/bhf/pages/_navi.html.haml
53
+ - app/views/bhf/pages/macro/column/_extern_link.haml
54
+ - config/locales/de.yml
55
+ - config/locales/en.yml
56
+ - config/routes.rb
57
+ - lib/actives/asset.rb
58
+ - lib/actives/category.rb
59
+ - lib/actives/navigation.rb
60
+ - lib/actives/navigation_type.rb
61
+ - lib/actives/post.rb
62
+ - lib/actives/preview.rb
63
+ - lib/actives/static.rb
64
+ - lib/apdown.rb
65
+ - lib/kiosk.rb
66
+ - lib/rails/generators/kiosk/templates/initializer.rb
67
+ - vendor/assets/javascripts/kiosk/classes/NaviAdmin.js
68
+ - vendor/assets/stylesheets/kiosk/application.css.sass
69
+ - README.md
70
+ homepage: http://github.com/antpaw/kiosk
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project: nowarning
90
+ rubygems_version: 1.8.10
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: CMS for bhf
94
+ test_files: []