aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2013-09-17 09:56:00 -0400
committerScott González <scott.gonzalez@gmail.com>2013-10-24 09:19:42 -0400
commit604e0949e33ac53d07c707d1cd6934a73cc6e44b (patch)
tree19da0b7ef123cb2963b83add208fb62748869095
parentb7e3e4636f6e7848c3710e1c815b2f2977aac0a2 (diff)
downloadjquery-ui-604e0949e33ac53d07c707d1cd6934a73cc6e44b.tar.gz
jquery-ui-604e0949e33ac53d07c707d1cd6934a73cc6e44b.zip
Sortable: Moved helper methods into the widget prototype.
-rw-r--r--ui/jquery.ui.sortable.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index c76a02397..9553da5dc 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -15,14 +15,6 @@
*/
(function( $, undefined ) {
-function isOverAxis( x, reference, size ) {
- return ( x >= reference ) && ( x < ( reference + size ) );
-}
-
-function isFloating(item) {
- return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
-}
-
$.widget("ui.sortable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "sort",
@@ -65,6 +57,15 @@ $.widget("ui.sortable", $.ui.mouse, {
stop: null,
update: null
},
+
+ _isOverAxis: function( x, reference, size ) {
+ return ( x >= reference ) && ( x < ( reference + size ) );
+ },
+
+ _isFloating: function( item ) {
+ return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
+ },
+
_create: function() {
var o = this.options;
@@ -75,7 +76,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.refresh();
//Let's determine if the items are being displayed horizontally
- this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
+ this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
//Let's determine the parent's offset
this.offset = this.element.offset();
@@ -554,8 +555,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithPointer: function(item) {
- var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
- isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -572,8 +573,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithSides: function(item) {
- var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
- isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
+ var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
+ isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -846,7 +847,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//When entering a new container, we will find the item with the least distance and append our item near it
dist = 10000;
itemWithLeastDistance = null;
- floating = innermostContainer.floating || isFloating(this.currentItem);
+ floating = innermostContainer.floating || this._isFloating(this.currentItem);
posProperty = floating ? "left" : "top";
sizeProperty = floating ? "width" : "height";
base = this.positionAbs[posProperty] + this.offset.click[posProperty];
@@ -857,7 +858,7 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.items[j].item[0] === this.currentItem[0]) {
continue;
}
- if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
+ if (floating && !this._isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
continue;
}
cur = this.items[j].item.offset()[posProperty];
c { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.fonts;

import java.net.URL;
import java.util.Iterator;
import java.util.List;

import org.apache.fop.fonts.autodetect.FontInfoFinder;

/**
 * Adds a list of fonts to a given font info list
 */
public class FontAdder {
    private FontEventListener listener;
    private FontResolver resolver;
    private FontManager manager;

    /**
     * Main constructor
     * @param manager a font manager
     * @param resolver a font resolver
     * @param listener a font event handler
     */
    public FontAdder(FontManager manager, FontResolver resolver, FontEventListener listener) {
        this.manager = manager;
        this.resolver = resolver;
        this.listener = listener;
    }

    /**
     * Iterates over font url list adding to font info list
     * @param fontURLList font file list
     * @param fontInfoList a configured font info list
     */
    public void add(List/*<URL>*/ fontURLList, List/*<EmbedFontInfo>*/ fontInfoList) {
        FontCache cache = manager.getFontCache();
        FontInfoFinder finder = new FontInfoFinder();
        finder.setEventListener(listener);

        for (Iterator iter = fontURLList.iterator(); iter.hasNext();) {
            URL fontUrl = (URL)iter.next();
            EmbedFontInfo[] embedFontInfos = finder.find(fontUrl, resolver, cache);
            if (embedFontInfos == null) {
                continue;
            }
            for (int i = 0, c = embedFontInfos.length; i < c; i++) {
                EmbedFontInfo fontInfo = embedFontInfos[i];
                if (fontInfo != null) {
                    fontInfoList.add(fontInfo);
                }
            }
        }
    }
}